cancel
Showing results for 
Search instead for 
Did you mean: 

Problem when combining temporal data with fiori selection fields

DanielSchroeder
Explorer

Hi everybody,

I have a problem regarding the usage of selection fields in combination with temporal data (Date fields annotated with @cds.valid.from/.to) as described in the documentation.

When I enter either a validFrom or validTo date in the fiori frontend, the data will be built into the SQL-like query like a regular input field ("equal to"-comparison by default). Instead, it should be mapped to the proper parameters within the request, which are processed by the cds model to apply the validity logic. In case I leave the selection fields empty but set the proper parameter inside the service as follows:

this.before("READ", ["Books"], async (req) => {
    req._["VALID-FROM"] = "2020-01-01";
    delete req._["VALID-TO"];
});

the API will be called correctly and the logic of selecting entities for the given validity parameters works as intended.


Is there another way to map a selection field to the proper parameter inside the request? Or is this supported already by another feature I might have missed? Removing the validity parameters from the SQL query within the request and manually mapping it to the correct parameter seems like a bad idea to me.

To reproduce the issue you can clone this repo. You will have to deploy it to a hana database, otherwise the temporal API won't work (hana trials is probably the easiest). After deploying it, do 'export NODE_ENV=dev-hana' and 'cds run' to run the application against the deployed DB. Within /srv/admin-service.js (line 100) you can see how I hard coded the correct parameters, which should be set by the selection fields (but aren't). After changing the hard coded dates (and restarting the application), the returned books will change correctly.

Kind Regards
Daniel

Accepted Solutions (0)

Answers (0)