cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Unable to create/update when consuming a deployed service in CAP app

0 Likes
534

I have created a cap app and deployed to CF and all the CRUD functionality are working as expected. I tried to consume the deployed service as an OData service in another cap app. I created a service by consuming the existing OData services with only the required fields. I enabled the draft functionality but I am having issue with create and update from the app. I have implemented custom logic for all CRUD and create/update does not work as expected.

 

using { Material as mat } from './external/Material';
service Main {
entity Material as projection on mat.Material
{
    key matnr : String(40),
    type : String(4),
    desc : String(60)
}
}
annotate Main.Material with @odata.draft.enabled;
View Entire Topic
martinstenzig
Contributor
0 Likes

The custom handlers are only triggered once you save the draft into the "steady state". If you want to have custom handlers for draft entities you can find the instructions here: https://cap.cloud.sap/docs/node.js/fiori#programmatic-invocation-of-draft-actions

 

0 Likes

I tried using the above node js draft handler to have my custom logic and I also tried the one documented in the below link.

https://cap.cloud.sap/docs/node.js/fiori#draft-support

But these are not getting triggered when I create an entity that is a projection of an external Odata V4 services and I cannot save the draft values during create/update. When logging the events, I cannot see any events triggered for New, draftPrepare and draftActivate. However, when I create projection on local entitles defined within the schema, these events works as expected. 

--CREATE BUTTON (on object page aka save record) ------------------------------------------------------
[odata] - POST /odata/v4/person/$batch
[odata] - > CREATE /Person(id=999,IsActiveEntity=false)/PersonService.draftPrepare
[cds] - ️Uncaught TypeError: Cannot read properties of undefined (reading 'name')