Skip to Content
1
Jun 25, 2020 at 07:18 AM

Fiori Elements and temporal data

165 Views

Hi,

I'm finding a lot of troubles using temporal data with Fiori Elements.

In the backend I'm using nodejs services to expose my data, and on the front end I'm using ListReports and ObjectPages.

My db cds files are something like this:

@cds.odata.valuelist
entity Partners : cuid, managed, temporal {
  @title : '{i18n>name}'
  name                : String(64) not null;

  @title : '{i18n>services}'
  services            : Association to many Services
                          on services.partner = $self;
}

@cds.odata.valuelist
entity Services : cuid, managed, temporal {
  @title            : '{i18n>name}'
  name          : String(64) not null;

  @title            : '{i18n>partner}'
  partner       : Association to one Partners;
}

and my service cds file is something like this:

service AdminService @(
  path     : '/admin',
  requires : 'authenticated-user'
) {
@Consumption.filter.businessDate.at : true
define entity AdminService.Partners as projection on db.admin.Partners {
  * ,
  @Semantics.businessDate.from
  validFrom,
  @Semantics.businessDate.to
  validTo,
};

@Consumption.filter.businessDate.at : true
define entity AdminService.Services as projection on db.admin.Services {
  * ,
  @Semantics.businessDate.from
  validFrom,
  @Semantics.businessDate.to
  validTo,
};
}

When I navigate to my ListReports page for partners, I see the partners list, but when I click on a partner, I navigate to a not found page because the ListReport controller try to fetch a partner by ID, without the validFrom key and the OData service complain about that, so I have to use API Extensions to force the validFrom key with this custom code:

onListNavigationExtension: function (oEvent) {
      var ctx = oEvent.getSource().getBindingContext();
      var extensionAPI = this.extensionAPI;
      const model = this.getView().getModel();
      var navigate = function () {
        const key = decodeURIComponent(
          model.createKey("Partners", ctx.getObject())
        );

        extensionAPI
          .getNavigationController()
          .navigateInternal(model.getContext("/" + key));
      };
      extensionAPI.securedExecution(navigate, {
        busy: {
          check: false,
        },
        dataloss: {
          popup: false,
        },
      });

      return true;
    },

Now I've fixed the not found problem, but I'm facing another problem with services: sometimes the ObjectPage fetch partner's services through the right URL

GET Partners(ID=guid'55cf4a3a-3bc5-49bb-b99b-7434b4587f5f',validFrom=datetimeoffset'2020-01-01T00:00:00Z')/services?$skip=0&$top=10&$select=name,ID,validFrom

other time through the wrong URL

GET Partners(guid'55cf4a3a-3bc5-49bb-b99b-7434b4587f5f')/services?$skip=0&$top=10&$select=name,ID

showing an alert in which I'm notified about a problem with services.

Any ideas how to resolve all my issues? The only help I found online is this https://help.sap.com/viewer/cc0c305d2fab47bd808adcad3ca7ee9d/1809BW.001/en-US/b10c3654e6424d839a4b93f2d938d7f7.html