Skip to Content
0

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

Jun 21, 2017 at 01:43 PM

22

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers