Triggering SAP Build Process Automation Workflow from a Custom SAP Fiori Application
In this blog, we’ll explore h to integrate SAP Build Process Automation with a custom SAP Fiori application. This involves creating a workflow in SAP Build Process Automation, setting up an API trigger, and calling this workflow from a Fiori application.
Steps to Trigger the Workflow
- Log in to SAP Build Process Automation
Navigate to the SAP Build Process Automation application.
- Click on “Create” button to create a New Business Process.
Select Business Process
- In the Create a Business Process Project dialog box, do the following:
- Enter a Project Name: Sales Orders Management
- Enter a Short Description: Sales Orders Management Project
- Choose Create
-
- Create your process
- Open the process and create a API trigger
- Click on add API Trigger
- Once API trigger is created save the process and release and deploy.
- After creating API Trigger, we can see this trigger in Control Tower and we can trigger this Process from any SAP Fiori Custom application.
- Copy the URL, payload and we can trigger the process from postman or any custom UI5 application
Payload: {
“definitionId”: “us10.cpi-workzone-dev-z49850t9.customfioriapproval.customApprovalProcess”,
“context”: {}
}
7.Creating a Data Type and adding this data type to our trigger.
- Add a Field vendorNumber type string.
- Add Data Type to trigger Process Inputs and Process Outputs
Click on configure button and add input.
Similarly add process output
Save, Release and Deploy
Now our api trigger is updated with process input variable and we can trigger the API from any UI5 application.
To trigger SAP Build Process API, you need a destination to be created in BTP cockpit.
Create an instance of SAP BUILD PROCESS AUTOMATION
Create a service key
Create a service key
Create Destination using client Id and clientsecret
Code to trigger Build Process Automation from UI5 application, in controller add the below method
_workFlowCall: function (oData) {
var url = “/spa_process_destination/v1/workflow-instances”;
var sUrl = this._getExternalServiceRuntimeBaseURL() + url;
var payload = {
“definitionId”: “us10.cpi-workzone-dev-z49850t9.customfioriapproval.customApprovalProcess”,
“context”: {
“vendordetails”: {
“vendorNumber”: “”
}
}
}
$.ajax({
url: sUrl,
type: “POST”,
dataType: “json”,
contentType: “application/json”,
data: JSON.stringify(payload),
beforeSend: function (xhr) {
xhr.setRequestHeader(“Accept”, “application/json”);
},
success: function (response) {
console.log(“Success: “, response);
}.bind(this),
error: function (error) {
console.log(“Error in POST call:”, error);
}
});
},
_getExternalServiceRuntimeBaseURL: function () {
var oComponent = sap.ui.core.Component.getOwnerComponentFor(this.getView());
if (oComponent) {
var sAppId = oComponent.getManifestEntry(“/sap.app/id”);
var sAppPath = sAppId.replaceAll(“.”, “/”);
var sAppModulePath = jQuery.sap.getModulePath(sAppPath);
return sAppModulePath;
} else {
console.error(“Component could not be found.”);
return “”;
}
},
Key Points
- Ensure the destination is correctly configured in SAP BTP Cockpit for seamless communication.
- Customize the context field in the payload to include relevant inputs required for your workflow.
By following these steps, you can successfully trigger SAP Build Process Automation workflows directly from a custom SAP Fiori application, enhancing automation and integration capabilities.