Skip to Content
0
Dec 02, 2020 at 09:12 PM

SuccessFactors OData API from SAPUI5 - Error calling /odata/v2/approveWfRequest API

121 Views Last edit Dec 02, 2020 at 09:53 PM 3 rev

Hello All,

I have built an SAPUI5 (v1.71.4) application which reads a custom MDF object exposed as an odata service and displays it in a table. I am using ODataModel read function but only get one record back instead of 5. If I paste the uri in a browser i get the full 5 recordset, but in the UI5 app the call only returns 1. I have also tried with urlParameters like this:

var oUrlParams = new Map();
oUrlParams.set("recordStatus", "pending");
oUrlParams.set("$expand", "wfRequestNav");

and also like this:

var oUrlParams = {
   "recordStatus": "pending",
   "$expand": "wfRequestNav"
};

That's my first issue. This is the read call:

When using oUrlParams the uri is only

oModel.read("/cust_OBJECT", //...etc

without url params the read call has the full uri like used in the browser:
oModel.read("/cust_OBJECT?recordStatus=pending&$expand=wfRequestNav", {
                //urlParameters: oUrlParams,
                success: function (oData, oResponse) {
                    console.log("oData:", oData);
                    var oCustModel = new sap.ui.model.json.JSONModel();
                    oCustModel.setData(oData);
                    this.getView().byId("idResultSet").setModel(oCustModel, "custModel");
                }.bind(this),
                error: function (oError) {
                    console.log(oError);

                }
            });

My second issue is on the retrieved record I am trying to approve the wfRequest by using the service at /odata/v2/approveWfRequest. It works in Postman if I use this url "/odata/v2/approveWfRequest?wfRequestId=5000L"

In my sapui5 code I am doing this to try to achieve the same result:

var wfRequest = {};
wfRequest.wfRequestId = "5000L";
oModel.create("/approveWfRequest", wfRequest, {
     success: function (oData, oResponse) {
          console.log(oResponse)
     },
     error: function (oError) {
          console.log("Error", oError);
     }
});

but with this I get the oError response (the workflow id is definitely valid because I've tried and verified through postman)

"error" : {
"code" : "COE_GENERAL_BAD_REQUEST", "message" : {
"lang" : "en-US", "value" : "ChangeSet index 1 - Invalid Workflow Request Id provided."
}
}
}
 -  sap.ui.model.odata.v2.ODataModel

I have developed the code in Web IDE and have maintained a destination with Basic Authentication.

What am I doing wrong? Any suggestions and ideas welcome. Please help!

P.