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!
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.
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.
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
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
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 ?
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 😐
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
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 :
Hi Prateek,
Please try calling the REST API via Postman or another tool and specify basic authentication.
Regards,
Christian
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
Thanks for the Nice Blog Post Christian Loos .
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.
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
Regards,
Christian
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
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,
Hi Crishtan,
Thank you ?
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
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.
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
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
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
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
Hi Christian,
Thank you, I will try it out this
Regards,
Raghavendra
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,
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
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.
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
Hello Christian:
In my launchpad, I can't see the box from de app, like your image
Your Launchpad
My Launchpad
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).
it's work. thank you!
Regards.
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,
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/
it’s work. Thank you Christian!
Regards,
Raghavendra
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.
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
It's working now. Thanks!
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.
Make sure you have the WorkflowInitiator role:
Thanks Chris, Initially I had all the roles, but I deleted them and recreated and now its working fine.
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
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
Hello Ikram,
You can find the API in API Business Hub.
POST/v1/workflow-instances
PATCH/v1/task-instances/{taskInstanceId}
Hope that helps,
Archana
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
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