Simple SAP Cloud Platform Workflow to retrieve alerts from an REST API
Introducing
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.
Result
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
cheers,
Fabian
…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.
Love it when people take services and slide them all together like this to make sense of things in bigger ways than just taking them individually! Thanks for taking the time to share your brilliant work!
yeah for sure, i think that should be one of the main aspects for an living sap community.
I’m staying tuned, for sure!
Very nice blog, @Fabian. Already looking forward to the sequel.
Great post Fabian!! Also thanks for the suggestions!!
You are the best!
Thanks
Martina
Hi,
Is the workflow available for the trial account for SAP Cloud Platform ?
Hi Denis -- not quite yet, but planned this year! Thanks for your interest and stay tuned for WF on trial.
Hi Fabian,
Thank you for this post. It has helped me get started. I require one clarification though. You have configured a UI5 application url as as URL in “html5apps” destination. What if I want another inbox which is configured to another UI5 app. How do I do it since I cannot use “html5apps” destination name again. I am new to the workflow concept. So please excuse my ignorance.
@everyone else in this forum,
If anyone has any suggestions to my above query, it will be greatly appreciated.
Thanks & Regards,
Harish
Hi Harish,
i´ve updated my blog, the html5apps destination is not longer requiered.
I think there was a change in the meanwhile, for details check the Help
br,
Fabian
Hi Fabian,
In the documentation it is given that we can give HTML5 and Component of a User task in JUEL expression.
But when i try to give a JEUL expression in HTML5 app name or Component name i am not able to deploy the workflow. Even if i give the HTML5 app name or Component name with one or more capitalized alphabet the 'deploy' button gets disabled.
Can you suggest me some way through which i can reassign HTML5 to a user task at runtime based on some condition.
Hi Fabian,
Thank you for the post, It really helps and I’m able to retrieve data on the html app which i have mentioned in the user interface property of User Task. I’m trying to get a particular view of the app which i have mentioned, but every time I’m getting the root view of the application. How can i render a particular view and not the root view?
Thank you!
I understand there is not much flexibility around assigning the task to a set of users. Is there a way to dynamically work out the list of users and assign the workflow to the list?
Hi Pranav
You can acheive the same using 2 methods:
Great post Fabian. Just wanted to know if it is possible to trigger the workflow from the UI5 application itself, and pass the data to a new instance. Is it feasible?
Hi Dibya,
It is totally possible to trigger workflow from UI5 application and pass data to the newly created workflow.
You can extend your controller to create a function which will be triggered based on a UI event and based on that event you can create a new workflow with context data for that workflow instance.
Following link explains the procedure:-
https://help.sap.com/viewer/f63bbdc234ce4211ab2cdb44564a0acd/Cloud/en-US/a15d98916b1d4810b3d4a25dc38a0d85.html