Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Sesh_Sreenivas
Product and Topic Expert
Product and Topic Expert
0 Kudos
With the SAP Cloud Platform Workflow Service CW48 2017 (28-Nov-2017) release, the following enhancements are available:

Enhancement to task-instances REST API


The REST API is enhanced to support updating the following properties of a task instance:

  • Due Date

  • Priority

  • Description and

  • Subject


The task-instances REST API will help you to retrieve all active, cancelled or completed user task instances for a given workflow instance ID. First, let us query the task-instances to understand what the API can do, then we shall update the properties mentioned above.

Get Workflow Instance ID


As per the REST API documentation for the task-instances GET method, we need to pass a query parameter - workflowInstanceId. This can be retrieved by calling the workflow-instances GET method.

The REST API URL to get all the running workflow-instances can be determined as below:

https://bpmworkflowruntime{ProviderAccountname}-{consumerAccountName}.{landscapeHost}/workflow-servi.../v1/workflow-instances

For example, my API endpoint could be https://bpmworkflowruntimew1111111-w999999.hanatrial.ondemand.com/workflow-service/rest/v1/workflow-... in a trial landscape.

If you run this API using a rest client like Postman, you would get an output similar to the one below. Each of the records in the JSON output corresponds to one workflow instance. The "id" represents the workflow instance id, which you could use in the task-instances API to retrieve all active, cancelled or completed user tasks.
[{
"id": "24a96c50-d365-11e7-98b4-00163e455253",
"definitionId": "onboarding",
"definitionVersion": "71",
"subject": "Employee onboarding for ID 103161",
"status": "RUNNING",
"businessKey": "103161",
"startedAt": "2017-11-27T11:21:41.834Z",
"startedBy": "Lorin",
"completedAt": null
},
{
"id": "1f66fcc2-d365-11e7-98b4-00163e455253",
"definitionId": "onboarding",
"definitionVersion": "71",
"subject": "Employee onboarding for ID 103156",
"status": "RUNNING",
"businessKey": "103156",
"startedAt": "2017-11-27T11:21:33.013Z",
"startedBy": "Lorin",
"completedAt": null
}]

Get All User Tasks for a Workflow Instance


The API to get all the user tasks for a given workflow instance is the following:

https://bpmworkflowruntime{ProviderAccountname}-{consumerAccountName}.{landscapeHost}/workflow-servi...

Pick the first record from the previous API, and pass that as a query parameter to get all the user tasks for that workflow instance.

https://bpmworkflowruntimew1111111-w999999.hanatrial.ondemand.com/workflow-service/rest/v1/task-instances?workflowInstanceId=24a96c50-d365-11e7-98b4-00163e455253
[{
"activityId": "usertask2",
"claimedAt": null,
"completedAt": null,
"createdAt": "2017-11-27T11:23:32.754Z",
"description": "The manager approves the equipment list proposed by the buddy",
"id": "66c6a010-d365-11e7-9bf0-00163e455ed9",
"processor": null,
"recipientUsers": [
"P1942191773"
],
"recipientGroups": [
"OnboardingManager"
],
"status": "READY",
"subject": "Approve Equipment for Kate Beckett",
"workflowDefinitionId": "onboarding",
"workflowInstanceId": "59155c56-d361-11e7-98b4-00163e455253",
"priority": "MEDIUM",
"dueDate": null,
"createdBy": "Lorin"
}]

As you can see from the above output, a user task will contain various properties including priority, dueDate, Description and Subject. Note down the task instance id (in the above json it is 66c6a010-d365-11e7-9bf0-00163e455ed9) as we require in the next step.

Update priority for a user task


Now, let us use the PATCH method of task-instances to update the priority of the task to Very High from Medium. The PATCH method is CSRF protected, and hence you need to get a token to validate your request through the API described in the documentation.

The task-instances PATCH method is defined as below:

https://bpmworkflowruntime{ProviderAccountname}-{consumerAccountName}.{landscapeHost}/workflow-servi...

The API URL after replacing the placeholders with the actual value could be:

https://bpmworkflowruntimew1111111-w999999.hanatrial.ondemand.com/workflow-service/rest/v1/task-inst...

In your rest client, change the method to PATCH, set the XSRF token in the message header and create a JSON body similar to the one shown below. In the example, I do not want to update the context or any other property other than priority.



Refer to the API documentation for the enumerations to be used for priority and other attributes which can be modified.

Enhancement to My Inbox


With CW48 2017 release, user task recipient can sort by the user who created a task in My Inbox.

The sort and filter options in My Inbox was already available, but with the current weekly release you can now sort the task list (master page) based on the user who created the task. The user information is derived from the initiator of the workflow and is available as part of the task-instances API which was explained above.