cancel
Showing results for 
Search instead for 
Did you mean: 

Build Process Automation Custom Form - Consuming API via Destination

Giampaolo
Participant
283

Dear community,
we are creating a workflow with SAP BPA that uses a custom form. In this form we need to make POST and DEL calls consuming SAP oData.

SAP is reachable via Cloud Connector, the Destination has been created, imported into BPA, Actions have been created to test that everything is working correctly. Up to this point everything is fine.

The problem arises when we try to use these services in the custom approval form controller.

96bTKi6rRH.png

 

 

 

 

 

 

In xs-app-json we added this route

{
"source": "^/odata/(.*)$",
"target": "/$1",
"destination": "sap_process_automation_odata",
"authenticationType": "none",
"csrfProtection": false
},

in form.controller.js we added this code

_updateOdata: function() {
$.ajax({
url: that._getODataURL(),
method: "GET",
async: false,
contentType: "application/json",
headers: {
"X-CSRF-Token": "fetch",
},
complete: function (result, status) {
token = result.getResponseHeader("X-CSRF-Token");
console.log("SapToken: " + token);
},
});
/* OTHER CODE*
}

_getODataURL: function () {
  var appId = this.getOwnerComponent().getManifestEntry("/sap.app/id");
  var appPath = appId.replaceAll(".", "/");
  var appModulePath = jQuery.sap.getModulePath(appPath);

return appModulePath + "/odata/sap/ZODATA";
},

What I expect to happen with this code is to get the token to use for the next POST or DEL call, but the call fails with a 500 or 404 error.

The way the route is configured, the address should resolve to
https://<host>:44301/sap/opu/odata/sap/ZODATA
but evidently something is not correct.

I add that this form allows you to write and read files in the BTP Document Management Service via API, using a very similar approach and this is working.

I have done this in the past on other custom task forms, but with Workflow Manager (maybe there is some difference that we have not noticed).

Anyone have any suggestions?

Thanks and Best Regards,
Giampaolo

SAP Build Process Automation 

View Entire Topic
Giampaolo
Participant

I add the correctly formatted code

notepad++_noJyIp483W.png

Giampaolo
Participant

SOLVED!
The approval form generated with the BAS does not have the default_connectivity and default_destination service references in the mta.yml file.

In order to use onPremise type destinations, it is therefore necessary to:

  1. Create the default_connectivity service (service Connectivity Service, plan lite)
  2. Create the default_destination service (service Destination Service, plan lite)
  3. Update the mta.yaml file of the Approver form custom

At this point, the onPremise destination will be usable.