Skip to Content
Author's profile photo Christian Loos

Getting started with the Workflow service in the free Trial account (2/2)

In the first part of this blog series, we have deployed our first workflow to the SAP Cloud Platform.

To see the deployed workflows in your account, there is a “Monitor Workflow” app. Before you can run it, you need to add it to your Fiori launchpad.

Adding the workflow apps to your home page

Open the Portal Administration space (you can find the link on the Portal service tile) and open the “Site Directory” menu. Choose the “Default” site and click on the link to open it.

Now, click on your user menu and use the App Finder to add all three apps from the Workflow catalog to your Home Page: My Inbox, Monitor Workflows (Definitions) and Monitor Workflows (Instances).

 

Check the deployed workflow definition in the “Monitor Workflow” app

Once you’re done, go to your Home page and open the Monitor Workflows (Workflow Definitions) app.

Here, you should see your deployed Workflow. Since we deployed it for the first time, the version number is “1”. Each new deployment will increase the version number.

You can now open the running instances for this workflow (there are none yet) or start a new instance.

Typically, you would start a new workflow instance either from an UI or from an another application, via the Workflow service REST API, but the monitoring app provides an easy way to start workflows for testing purposes.

When starting a workflow, you can provide a JSON structure as input data. These JSON objects get stored within the workflow as context data. You can use them throughout the workflow e.g. in Gateways, user tasks or service tasks. Read more on how to handle workflow data here.

Since the workflow we modelled contains only a start and end event, if you start an instances it will immediately get completed and hence not be visible under “Show instances” (you can still retrieve completed instances through the REST API).

So let’s go back to the Web IDE and enhance our workflow with a user task.

Adding an user task to the workflow

In the workflow editor, select the “User Task” symbol from the palette and click on the connector between the start and the end event.

Change the name to “ApproveBook” in the properties under the “General” tab.

Now, switch to the “Display Texts” properties tab.

Here, you can define the task subject. This is the text that the user will see in his inbox.

We want to show the book name, so let’s use an expression which references a field from the sample JSON structure above (read more on how to use expressions here).

Enter “Approve ${context.product}” in the Subject field.

Move on to the “Recipients” tab to define who will receive the task.

Enter your user ID exactly as it shows up in the user info (please note that this field is case sensitive).

As a last step, switch to the “User Interface” tab.

Here, you will have to enter the application and component name of an SAPUI component, which will display the task in the inbox.

For now, let’s just enter some dummy values (test/test).

Save and deploy the workflow again and then switch back to the monitoring app. Note that the Version of your workflow definition has increased from “1” to “2”.

Start a new workflow instance

Start another workflow instance, and leave the standard JSON input as is.

When you now open the “Show Instances” view, you should see the one instance you just started:

 

The execution log shows, that there is a task waiting in the inbox.

Open the task in My Inbox

So let’s go back to the Fiori launchpad home page. As you can see, the “My Inbox” tile shows one open task.

If you open the inbox, you see the task with some header information, but without any further details or actions.

In order to actually complete the task (and thereby the workflow), you will have to build a SAPUI component as described here.

Update: Please also check out the new blog series by Archana Shukla here:
https://blogs.sap.com/2017/10/12/part-1a-build-your-custom-html5-application-in-sap-webide-for-workflow/

However, we will leave this for another blog, and end our introduction here.

Summary

You have seen how to model and deploy workflows using the SAP Web IDE, start and monitor workflow instances via the Monitor Workflow app and see user tasks in the My Inbox.

Check out the Workflow Developer Guide or explore the REST APIs in the SAP API Business Hub sandbox environment.

Share your feedback, and stay tuned for more blogs on SAP Cloud Platform Workflow!

 

Assigned Tags

      44 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Phil Cooley
      Phil Cooley

      Thanks Christian, not sure why but I did not have a Default FLP site in my list. I did have other FLPs in my trial account but could not find any Workflow related tiles within them. Any ideas?

      Also, just to understand this, I need to build a My Inbox type of app and deploy this prior to starting this exercise - using the SAPUI components included in the Workflow sap.help instructions.

      OK...will attempt over the coming days.

       

      Author's profile photo Dhimant Patel
      Dhimant Patel

      Hi Phil, looks like a little manual work is involved.  While you will see the apps, catalog, and group being shared, it does not assign any roles.  So, go to FLP Site Admin, click Content Management > Catalogs > Workflow.  In Workflow Catalog, click edit (bottom right) and click Roles button (on top), then add Everyone Role to it.  Now if you re-launch your default FLP and try adding apps, you will see Workflow catalog available with three apps.  Hope this helps.

      Author's profile photo Christian Loos
      Christian Loos
      Blog Post Author

      Hi Phil,

      No, you  don't need to build your own inbox app, you can use the standard My Inbox app.

      Just make sure to have a proper role assignment for the Workflow catalog as described by Dhimant.

      Regards,

      Christian

       

      Author's profile photo Phil Cooley
      Phil Cooley

      Doh! Thanks Dhimant - should have picked up on this! Thanks for providing this information, I can now continue on with my Part 2 of the workflow exercise.

       

      Thanks!

      Phil

      Author's profile photo Prateek Vinod Chadha
      Prateek Vinod Chadha

      Thanks Christian,

       

      I was going through your tutorial. When I  go to app finder to add apps mentoned : My Inbox, Monitor Workflows (Definitions) and Monitor Workflows (Instances), I do not see any of these applications. Also in the cockpit under subscriptions I do not find above apps. How can I subscribe to these applications ?

       

      Author's profile photo Prateek Vinod Chadha
      Prateek Vinod Chadha

      In another account I am able to see the above apps, but when I go to monitor workflow app, I am not seeing the deployed 'myFirstWorkflow' app 😐

      Author's profile photo Christian Loos
      Christian Loos
      Blog Post Author

      Hi Prateek,

       

      Are you sure you have also deployed the workflow in this other account?

      Did you get a success message when deploying the workflow?

      Can you retrieve the definition via the REST API?

       

      Regards,

      Christian

       

      Author's profile photo Prateek Vinod Chadha
      Prateek Vinod Chadha

      Hi Cristian,

       

      Thank you for your response. Unfortunately our system was down so was not able to reply you  back yesterday.

      Yes Application seems to be deployed :

      when I call the service : /workflow-service/rest/v1/workflow-definitions I get following HTML response :

       

      Author's profile photo Christian Loos
      Christian Loos
      Blog Post Author

      Hi Prateek,

       

      Please try calling the REST API via Postman or another tool and specify basic authentication.

       

      Regards,

      Christian

      Author's profile photo Prateek Vinod Chadha
      Prateek Vinod Chadha

      Hi Crishtan, Thank you 🙂

      I figured out the problem, I was deploying the whole project and we are supposed to deploy the workflow file. Now it is working

      Author's profile photo Nithin Bacholla
      Nithin Bacholla

      Thanks for the Nice Blog Post Christian Loos .

      Author's profile photo Former Member
      Former Member

      Hi Christian,  in user task i have used one HTML5 application, in that I have binded data using json. but in my inbox app I am getting UI but data is not coming.

       

      Author's profile photo Christian Loos
      Christian Loos
      Blog Post Author

      Hi,

      Make sure you have created the JSON model correctly and access the data via the "/context" prefix as described in the documentation: https://help.sap.com/viewer/f63bbdc234ce4211ab2cdb44564a0acd/Cloud/en-US/6fc4c8d9d9264fcba991ec9a37ad1851.html

       

      <Text text="{/context/text}" maxLines="0" id="__text0"/>

      Regards,

      Christian

      Author's profile photo Raghavendra H K
      Raghavendra H K

      Hi

      Actually I am doing workflow for  vendor data creation for this app multiple level of approvals are there. Can u please explain how to achieve multiple levels of approving.

       

      Best regards
      Raghavendra

      Author's profile photo Christian Loos
      Christian Loos
      Blog Post Author

      Just add multiple user tasks in a sequence to the workflow.

      If the number of approval steps is dynamic (meaning it depends on the business context how many steps are necessary), just model a loop and check after each iteration whether there are additional steps required,

      Author's profile photo Raghavendra H K
      Raghavendra H K

      Hi Crishtan,

      Thank you ?

      Author's profile photo Raghavendra H K
      Raghavendra H K

       

       

      Hi,

      Thank u , Multiple Approval is working now.

      In My Inbox ,  admin can approve or reject the request. I have one question how can he monitor or check  the approved or rejected request. In some blog they have mentioned that after genereating the IDP , It gets added in the SAP Cloud Platform Identity Authentication Administration, but I am not having sufficient privileges to access it, Is there any alternate solution to check the approved or rejected request.

      Best regards
      Raghavendra

      Author's profile photo Christian Loos
      Christian Loos
      Blog Post Author

      You can check the workflow logs in the Monitor Workflows app, if the workflow instance is still running.

      Once it's completed, currently you can only retrieve the logs via the REST API.

      Author's profile photo Raghavendra H K
      Raghavendra H K

      Hi  Christian,

      Thank  u for quick response,

      Is it possible to call SCIM api while approving the task in my inbox and then getting the approved task in SAP  Cloud Platform Identity Authentication Administration console?

      Thanks & Regards,

      Raghavendra

      Author's profile photo Christian Loos
      Christian Loos
      Blog Post Author

      Hi Raghavendra,

      I'm not sure I understand your question. How is your custom vendor data creation workflow related to the IAS Administration console? Do you call some IAS APIs (e.g. to create users) as part of the workflow?

      Regards,

      Christian

       

      Author's profile photo Raghavendra H K
      Raghavendra H K

      Hi Christian,

      Thank u, I am really so happy the way you are helping me,

      I am not calling any IAS APIs.

      Yesterday u told to use  REST API to retrieve all workflow logs, but I am getting only one log details because there I have to mention the Workflow instanceId which is different for each logs, so I had mentioned the previous log details and I am getting the details of that previous log, but my requirement is to get the details of all the logs which admin has approved or rejected for that workflow.

      Thanks & Regards,

      Raghavendra

      Author's profile photo Christian Loos
      Christian Loos
      Blog Post Author

      Hi Raghavendra,

      If you want to provide some “admin” dashboard to track all requests in the system and who approved which, then the most efficient way is to store this information in your own custom database table (e.g. HANA) and expose it to your UI (e.g. via XSOData and Fiori Elements).

      In your workflow, after the approval task you can model service task. Here you can implement your own Java service, in which you can retrieve the task instances for the current workflow instance, including their status (e.g. completed) and their owners (approvers). Then you can insert this information into your database table which stores all the requests.

      Otherwise, everytime an user opens the dashboard, you would have to loop through all workflow instances via REST API and parse the individual logs.

      In the future, we plan to offer some configurable monitoring functionality for business users, which they can use to track requests.

      Regards,

      Christian

       

      Author's profile photo Raghavendra H K
      Raghavendra H K

      Hi Christian,

      Thank you, I will try it out this

      Regards,

      Raghavendra

       

       

      Author's profile photo Raghavendra H K
      Raghavendra H K

      Hi Christian,

      Thank u,

      Is service task is only used for business rules or we can use it for hana services also?

      and U had given one more solution for tracking  the request, so I have called ajax method for hana services  in my html5 application,

       

       

      but I could not able to post the data. I am getting following error,

      Author's profile photo Johannes Wienhold
      Johannes Wienhold

      I am following the script and was able to deploy the workflow. But after deploying, the workflow monitoring app, does not show the workflow.

      When following your instructions I see the following differences. After the deployment I get a pop-up asking to deploy to Fiori Lauchpad. 

      And if I follow the "register to SAP Fiori Launchpad" I get a screen where most fields are inactive and I cannot proceed. 

      When testing the workflow in Monitoring App, I can open the app, but the workflow instance is not shown.

      Looking at the HTML5 Application created I see the workflow app, but it has no destination created.

      Can you please advise, how to proceed.

      Thanks

      Johannes

      Author's profile photo Christian Loos
      Christian Loos
      Blog Post Author

      It looks like you deployed the (empty) UI5 project which contains the workflow definition.

      You only need to deploy the individual .workflow files (via the dedicated “Deploy to SAP Cloud Platform Workflow” context menu action).

      The Monitor Workflow app is a standard app which is already subscribed into your sub-account and doesn’t need to be deployed.

      You only need to add it into your FLP site.

       

      Author's profile photo Johannes Bacher
      Johannes Bacher

      Hello Christian,

      thank you a lot for this blog - i could easily follow the steps. Before that, i was trying around by using only the developer documentation, but without significant success.

      Why is there not a set of sample workflows available ? that would be a good enabler.

      Thanks, Johannes

      Author's profile photo Former Member
      Former Member

       

      Hello Christian:

       

      In my launchpad, I can't see the box from de app, like your image

       

      Your Launchpad

       

      My Launchpad

       

       

       

      Author's profile photo Christian Loos
      Christian Loos
      Blog Post Author

      Follow the this step from my blog:

      Click on your user menu (the user icon on the top left corner in your screenshot) and use the App Finder to add all three apps from the Workflow catalog to your Home Page: My Inbox, Monitor Workflows (Definitions) and Monitor Workflows (Instances).

       

      Author's profile photo Former Member
      Former Member

      it's work. thank you!

       

      Regards.

      Author's profile photo Raghavendra H K
      Raghavendra H K

       

      Hi Christian,

      Thank u for the blog,

      Is service task is only used for business rules or we can use it for hana services also?

      and U had given one more solution for tracking  the request, so I have called ajax method for hana services  in my html5 application,

       

       

      but I could not able to post the data. I am getting following error,

      Author's profile photo Christian Loos
      Christian Loos
      Blog Post Author

      Hi,

      using a service task, you can call any REST or OData service via HTTP/JSON.

      I'm not sure about your example - are you trying to call an HANA XS service from your custom task UI?

      If this is the case, please refer to the blog by Archana:
      https://blogs.sap.com/2017/10/22/part-3-calling-external-service-in-task-ui-of-sap-cloud-platform-workflow/

       

       

      Author's profile photo Raghavendra H K
      Raghavendra H K

      it’s work. Thank you Christian!

      Regards,

      Raghavendra

      Author's profile photo Former Member
      Former Member

      Hi Christian,

      The workflow instance which you have mentioned in the blog I am not able to view my instance in the workflow. I have followed the steps which you have mentioned still I am not getting it. Can you please help me on this.

       

      Author's profile photo Christian Loos
      Christian Loos
      Blog Post Author

      Hi Bhavya,

      If you cannot see the instance in the monitoring app, then either it has not been started or it has already completed (e.g. the workflow instance will automatically complete if you do not have a user task in between).

      Did you get an error message when starting the instance? If not, you can try to query the instances via the REST API:

      https://help.sap.com/doc/72317aec52144df8bc04798fd232a585/Cloud/en-US/wfs-core-api-docu.html#api-WorkflowInstances-v1WorkflowInstancesGet

       

      Regards,

      Christian

      Author's profile photo Former Member
      Former Member

      It's working now. Thanks!

      Author's profile photo V. Menta
      V. Menta

      Hi,

       

      When I try to start a new instance of my workflow from workflow definition app I am getting the error :

      The operation could not be performed due to missing permission.

       

      Can you help me to figure out what permissions I require. I already followed your part 1 blog and assigned all the workflow related roles before I started this exercise.

       

      Thanks.

      Author's profile photo Christian Loos
      Christian Loos
      Blog Post Author

      Make sure you have the WorkflowInitiator role:

      Author's profile photo V. Menta
      V. Menta

      Thanks Chris, Initially I had all the roles, but I deleted them and recreated and now its working fine.

       

      Author's profile photo JAVIER RUBIO
      JAVIER RUBIO

      Hello Christian,

      In the step --> Open the Portal Administration space and open the “Site Directory” menu. Choose the “Default” site and click on the link to open it --> the Default site is not visible hence I created a new Site but the workflow apps are not displayed either even I had deployed them along with catalog and group.

      Am I missing roles?

      Thanks,

      Javier

      Author's profile photo Mohammed Ikram
      Mohammed Ikram

      Hello Christian,

       

      I have a SAPUI5 screen, with 2 fields, which I send that to the backend by Odata service to create a record, I want to start the workflow, when , I press the submit button and call the oData service and approve the same record from My Inbox.

      How to achieve this, In your tip, you have mentioned about REST API, please elaborate.

       

      Please help

      Ikram

       

       

      Author's profile photo Archana Shukla
      Archana Shukla

      Hello Ikram,

      You can find the API in API Business Hub.

      Hope that helps,
      Archana

      Author's profile photo Sai Peddaiahgari
      Sai Peddaiahgari

      Hello Christian,

      Is there any possibility of creating the Workflow definition and deploying it through rest call or Odata API, Just like how we create the workflow task instances?

      The ask for above scenario is, If user created a workflow in C4C we wanted to create the workflow definition and deploying it with default user task instances in cloud platform. So that end user doesn't need to again create a workflow by logging into Cloud platform ?

       

      Thanks

      Sai

      Author's profile photo Christian Loos
      Christian Loos
      Blog Post Author

      Hi Sai,

      currently this is not available as a public API. In the Cloud Foundry environment, you could look into the transport service on CF, which I believe has a CLI for headless deployment of MTAs (including workflow modules).

      Regards,

      Christian