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