Skip to Content

‏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:

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:

  1. Start Event
  2. Service Task (this calls our API)
  3. User Task (to dispaly our Task)
  4. 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 “html5appsmanually, 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.

 

To report this post you need to login first.

15 Comments

You must be Logged on to comment or reply to a post.

  1. Moya Watson

    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!

    (3) 
  2. h d krishnamurthy

    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

     

     

    (0) 
    1. Fabian Lehmann Post author

      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

       

      (0) 
  3. Vimal Rawat

    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.

    (0) 
  4. Poltish Kumar

    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!

    (0) 
  5. Pranav Goswami

    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?

    (0) 
    1. Vimal Rawat

      Hi Pranav

      You can acheive the same using 2 methods:

      1. Use ‘PATCH’ request with  ‘/v1/task-instances/{taskInstanceId}’ api and patch some more users to the task instance.
      2. Pass the list of users as a context with task and use a JUEL expression (e.g. – ${context.approverList}) in the ‘USERS’ field of ‘RECIPIENTS’ tab.
      (0) 
  6. Dibya Ranjan Bhoi

    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?

    (0) 
    1. Vimal Rawat

      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

       

      (0) 

Leave a Reply