Calling bound / unbound CAP actions from Fiori elements application.

In this blog post, We will go through the process of calling CAP actions out of a JavaScript function using the “invokeAction” function of the SAP Fiori elements Edit flow API.

In CAP, actions can be bound to a specific entity or unbound and just be a part of the service. Bound actions can only be executed, when at least one entity is selected. Unbound actions can be executed anytime.

It is possible to invoke CAP actions out of a JavaScript function using the “invokeAction” function of the SAP Fiori elements Edit flow API.

Note: The purpose of this blog is mainly to demonstrate how to create a CAP action and call it from within the Fiori elements application.

 

I have taken the reference from

A controller extension offering hooks into the edit flow of the application 

CAP actions out of a JavaScript function using the “invokeAction” function of the SAP Fiori elements Edit flow API. 

In this article will discuss

1) An example of a simple CAP action would be the addition of two numbers.

2) How to use the custom action button to invoke the CAP action from the Fiori elements application.

Lets get started.

1) An example of a simple CAP action would be the addition of two numbers.

  • Create the simple CAP action in the service definition of the cap application as shown below.

vidhyasagarmule_13-1725723916966.png

 

  • The extension logic that will be written when the cap action is called is now displayed below.

vidhyasagarmule_14-1725724008306.png

 

  • I have created a custom action using the SAP FPM Fiori elements application, as indicated below.

vidhyasagarmule_3-1725721669094.png

vidhyasagarmule_4-1725721825428.png

 

  1. invoke CAP actions out of a JavaScript function using the “invokeAction” function of the SAP Fiori elements Edit flow API as shown below.

     

    vidhyasagarmule_9-1725722952543.png

    sActionName: The name of the action to be called.

    mInParameters:   

    1. contexts: For a bound action, a context or an array with contexts for which the action is to be called must be provided.
    2. label: A human-readable label for the action. This is needed in case the action has a parameter and a parameter dialog is shown to the user. The label will be used for the title of the dialog and for the confirmation button.
    3.  model: For an unbound action, an instance of an OData V4 model must be provided.
    4.  parameterValues: A map of action parameter names and provided values.
    5.  skipParameterDialog: Skips the action parameter dialog if values are provided for all of them in parameterValues.
  • Now that the action can be triggered via the UI, let’s observe the outcome.

vidhyasagarmule_12-1725723440946.png

Conclusion

After going through this post, you should be able to call the bound and unbound CAP actions from Fiori elements using  Edit Flow. I hope this guide has been helpful and if you have any questions or comments, please feel free to leave them below.

 

      Please follow me for the future updates.

vidhyasagarmule_10-1725723030962.png

 

 

 

 

 

 

Scroll to Top