on 12-26-2021 8:16 PM
Hi all,
I have an entity set (Offers) which contains "guest" attribute that should be edited by selecting a desired row and clicking on "Book" button on the list report page .
entity Offers: managed
{
key ID : UUID @(Core.Computed : true);
owner : String ;
place : String;
startDate: Date;
endDate : Date;
description : String;
status: String default 'Available';
guest : String
}
I am trying to call CAP bound action action from Fiori List report page that takes as input "myguest" and then update the entity field "guest" by selecting a desired row from the list and clicking on "book" button.
after clicking on the Book button I get the Error below
here is my service definition
Service ParkingService {
entity Offers as projection on pm.Offers actions {
action assignGuest(
@UI.ParameterDefaultValue : in.guest
myguest : String
);
};
annotate ParkingService.Offers with @odata.draft.enabled;
}
and here is my custom handler
const cds = require('@sap/cds')
module.exports = function () {
const { Offers } = cds.entities
this.on ('assignGuest', async (req)=> {
const id = req.params[0],
gst = req.data.myguest;
const n = await UPDATE(Offers,id)
.with({guest: gst, status: "booked"})
.where({status:'Available'});
n > 0 || req.error (404)
})
}
I would much appreciate any feedback!
Best Regards
Mariam
Hi idman,
within the implementation of your action, you use this line:
const id = req.params[0]
According to the documentation, req.params returns an object for compound keys. In your case, the variable "id" does not only hold the value for "ID" but also for "IsActiveEntity".
The value for "IsActiveEntity" must not be provided to the query API as the underlying table does not have this column.
It's a bit unfortunate that there is the need for fiddling around with "IsActiveEntity" within your custom handler but as of now there is no better solution. However, we are working on it already.
Long story short, please make sure that the object you provide as second parameter in
const n = await UPDATE(Offers,id)
does not contain the property "IsActiveEntity" anymore, if it's value is 'true'.
Best regards,
Johannes
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.