cancel
Showing results for 
Search instead for 
Did you mean: 

Call Bound Actions/Functions from Fiori Controller in CAP.

richa_dwivedi
Explorer
0 Kudos

Hello everyone,

How we can call bound functions from fiori controller, in both odata v2 and v4, i tried calling it from controller but getting following error.

In V2:

Error:

Log-dbg.js:493 2023-10-19 15:48:14.624899 Function '/FunctionName' not found in the metadata - EventProvider sap.ui.model.odata.v2.ODataModel sap.ui.model.odata.v2.ODataModel

Code:

this.getModel().callFunction("/FunctionName", mParameters);








cguttikonda24
Participant
0 Kudos

Hi Richa,

The error says that it doesnt find the function in the metadata.

Did u happen to check the metadata and this function name under function imports section.

richa_dwivedi
Explorer
0 Kudos

cguttikonda_henkel Yes I've checked, function is available in metadata, like this.

<Function Name="onEdit” IsBound="true" IsComposable="false">
<Parameter Name="in" Type=“Service.EntitySet/>
<ReturnType Type="Edm.String"/>
</Function>
cguttikonda24
Participant
0 Kudos

Is your model a named model just to be sure?

katan_patel
Participant
0 Kudos

In Odata V4 you could try the following.

The trick for me was to pass the fully qualified name (including namespace) of the function.

In this example "ResolutionPlanSteps" was my entity and the bund function was "namespace.srv.IncidentsService.completeStep".

My CAP service returns success messages via the Request Object methods, which I read in "then" callback for the promise

let path = "/ResolutionPlanSteps(" + id + ")/namespace.srv.IncidentsService.completeStep(...)"

let oActionODataContextBinding = this.getModel().bindContext(path); 
oActionODataContextBinding.execute().then( (response) => { 
  var oActionContext = oActionODataContextBinding.getBoundContext();
  var messages = oActionContext.getModel().getMessagesByPath(""); 
  var message = messages[messages.length - 1]; 
  if (message.type !== "Success") { 
    MessageBox.error(message.message); 
    return; 
  } 
  MessageBox.success(message.message); 
})

Accepted Solutions (0)

Answers (0)