In this blog i will show you a quite simple scenario how we can fetch data from an REST API to create an WF task.
Futhermore we will have two additional blogs, were we can see how we can enhance our scenario:
- Using SAP Cloud Platform Integration to start a SAP Cloud Platform Workflow
- SAP Cloud Platform Integration and SAP Cloud Platform Workflow just a good combination
Finally check the other blogs about the new SAP Cloud Platform Workflow service.
Enter the new Workflow service
From the SAP CP cockpit we will go to the services and click on the new Workflow tile:
From the worflow service overview we can now enter the “Workflow Editor”.
Define the Workflow
In the WF Editor we can now create our simple WF:
The desing process is similar to the devolpment in SAP CP Integration, with one little restriction which hopefully will fixed/redesigned.
Before you can deploy the WF you must save the WF model. But in this step you can only save this locally on your computer/device and not directly in SAP CP ;o) And i want save my WF in the SAP CP!
From my perspective it would be fine if we have a similar aproach like on SAP CP Integration, where we can create packages to store our artifacts.
….Back to the WF
Now we create the folowing 4 objects:
- Start Event
- Service Task (this calls our API)
- User Task (to dispaly our Task)
- End Event
The WF looks now like this:
A really nice feature, are the speed buttons where you can access all objects instead of the palette:
The Service Task
In the Service Task we define our API call, for me an REST API.
Please check the SAP Help for details.
As u can see we using here an SAP CP destination, which i´ve defined in the cockpit which points to my API URL..
The interesting part of this config is the “Response Variable” here you define the context of the HTTP response. This is used later in my SAP UI5 app to display the data.
The User Task
In the User Task u define some general settings, like the Display Text.
Enter now the the user(s) (for me my suser) which can get the task in the “My Inbox” app.
Finally we create now an SAPUI5 (SAP Help) app and enter the app name an the “SAPUI5 Component”, which u can found in the “Component.js” file:
Update 30.05.2017: So far i´ve seen the html5apps destination is not longer required.
Please check the Help for more details about this topic.
An important thing which, i´ve read over more than once is this one: My Inbox includes two predefined destinations: bpmworkflowruntime and html5apps. bpmworkflowruntime is configured automatically during the onboarding process, but you must configure html5apps yourself according to your scenario. It integrates a custom task UI into My Inbox. Therefore, the destination must point to the HTML5 application that contains your custom task UI. So if u have deloyed your app to SAP CP u need to create the “html5apps” manually, which points to the URL of your SAP UI5 app:
Now u can deploy your WF process, by clicking on the “deploy” button on the upper right corner of the WF editor.
Start your WF
In the “Workflow Definitions” tile you should now see the newly created WF:
By clicking on the “Star New Instance” button you start now manually the WF.
In the upcoming popup you can see an sample JSON context, which will be passed to the WF.
In my scenario i would pass an empty context, because i will use the API call to retrieve my data.
Finally in the “My Inbox” app you can now see the new task with the data which are retrieved through the API call:
Check also my next blog to see how we ca start the WF timer based via SAP Cloud Platform Integration
…and stay tuned i would write in the next blog how we can combine this together with SAP CP Integration to create a WF task and an Cloud 4 Service ticket.