cancel
Showing results for 
Search instead for 
Did you mean: 

Calling default actions inside SAP CAP event handlers

0 Kudos

Hi experts!

I have a question with regards to calling default actions in SAP CAP event handlers. The documentation provides that you can call actions using the syntax

srv.on('firstMethod', (req,next) => {
    const otherService = cds.connect.to('OtherService');
    otherService.secondMethod({...});
});

In my project, I would like to call a couple of default actions (draftPrepare and draftActivate) used by Fiori Elements draft handling. However, the following code does not seem to work

srv.on('firstMethod', (req,next) => {
    const otherService = cds.connect.to('OtherService');
    otherService.draftPrepare({...});
});

It seems like there is some issue with the request not being properly passed to the draftPrepare action, is there some way of achieving this? And in general, is it possible to call default methods using the syntax provided above? Any help would be much appreciated!

Best regards,

Jibbril

Accepted Solutions (1)

Accepted Solutions (1)

mariya_yordanova
Explorer

Hi jibbril2,

in general this works, but not for draft related actions. We are working on an API to interact with drafts.

Best Regards

Maria

0 Kudos

Hi Mariya,

Ok, thanks for letting me know!

Best Regards,

Jibbril

Answers (1)

Answers (1)

0 Kudos

Hi mariya.yordanova,

we´re struggling with similar problems where the cds.draftPrepare and cds.draftActivate are not passed correctly to trigger underlying actions.

Has this feature been delivered in the meantime?

Thanks & Best regards,
Alex

Steven-Mason
Explorer
0 Kudos

Hello alexander.patterer,

Were you ever able to find a way to execute the draftPrepare and draftActivate actions? Thanks!

Best Regards,
Steven