Call deployed CPI iflow from BTP sapui5 application by using ajax

Cloud process integration can be used to do process integration, but also can be used to simplify development . We can put together backend service in an iflow for a front end application like SAP UI5 . Today I will  demo the process .  To simplify the demo, I will demo the process base on the blog Trigger a Workflow Instance from a SAPUI5 Application developed in a Multitarget Application by Mariajose Martinez . The code is in github repository ui5workflowproject.

Step 1,  Deploy an iflow in Cloud process integration :

The following is the code in script1.grouvy

import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
def Message processData(Message message) {
def body = message.getBody(java.lang.String) def messageLog = messageLogFactory.getMessageLog(message) if (messageLog != null) { messageLog.addAttachmentAsString('ui5message', body, 'text/plain') } return message
}

After deployment, the runtime is in the following screenshot :

Step 2, create destination  for  cloud process integration runtime service key in BTP cockpit .

Step 3, Deploy the code from ui5workflowproject. The following some code related with Iflow rest api call .

Please note the following rout is added in xs-app.json under the module ui5workflowproject-approuter, Not under the module ui5applicationmodule .

Step 4 , Test from deployed sapui5 application

https://sap-internal—p-t-cee-iacapj-dev-ui5workflowproject-approuter.cfapps.eu10.hana.ondemand.com/ui5applicationmodule/index.html

Step 5, Check the result in Cloud Process Integration

The End!

Thank you for your time for reading!

Best regards!

Jacky Liu