cancel
Showing results for 
Search instead for 
Did you mean: 

"Uncaught (in promise)" exception when using oModel.callFunction()

martin_bangiev
Explorer
0 Kudos

Hello,

I created new import function "Approve" (there is also a "Reject", but let's focus on only one of them) in my oData Service:

The approve information is returned by the $metadata request

<EntityContainer Name="ZMY_SRV_Entities" sap:supported-formats="atom json xlsx" m:IsDefaultEntityContainer="true">
  <EntitySet sap:content-version="1" Name="ActivitySet" sap:updatable="false" sap:creatable="false" sap:pageable="false" sap:deletable="false" EntityType="ZMY_SRV.Activity"/>
  <FunctionImport Name="Approve" m:HttpMethod="GET" EntitySet="ActivitySet" ReturnType="ZMY_SRV.Activity">
    <Parameter Name="ACTIVITY_ID" Type="Edm.String" Mode="In"/>
    <Parameter Name="NOTE" Type="Edm.String" Mode="In"/>
  </FunctionImport>
</EntityContainer>

which I am trying to address when a button is clicked via my view controller:

var oModel = this.getModel();
oModel.callFunction(
  "/Approve", "GET", {"ACTIVITY_ID": "424242", "NOTE": "test" }, null, 
  function(oData, response) { sap.ui.commons.MessageBox.alert("Success!"); },
  function(oError){ sap.ui.commons.MessageBox.alert("Error!"); }
);

I tried to perform the call with explicit parameters too (with or without the quotes for parameter the names):

var oModel = this.getModel();
oModel.callFunction(
  "/Approve", {"urlParameters": {"ACTIVITY_ID": "424242", "NOTE": "test" }, "success": 
  function(oData, response) { sap.ui.commons.MessageBox.alert("Success!"); },
 "error": function(oError){ sap.ui.commons.MessageBox.alert("Error!"); }}
);

However at the end I see an exception in the browser console:

I found similar topics online, but most of them were not answered, so any ideas would be appreciated.

Thanks,

Martin

Accepted Solutions (0)

Answers (0)