Skip to Content
Author's profile photo Seshadri Sreenivas Ramanarayanan

How to Configure SAP CP Workflow User Tasks

In this blog I explain how you can configure user tasks in SAP Cloud Platform Workflow, and how to take full advantage of the available features for your use case.

A user task is a flow object in the workflow that illustrates a task that a human performs. Whenever the process control reaches the user task, the corresponding recipients of the user task will see a task appearing in the My Inbox application. Here, the user is presented with the title & description of the tasks along with other details to take an informed decision in order to complete the task.

For example, when you create create a leave request, a user task is created for your manager to approve. The manager could see information like type of time-off, start & end date of the time-off, who triggered the time-off request, etc. so that he/she can take an action (Approve/Reject the request).

In the workflow editor, to add a user task you can either drag and drop the ‘User Task’ from the palette to the editor or (even better) use the speed buttons to add them to the workflow model.

The user task requires the following information to be complete:

  1. Name, Documentation & Display Texts.
  2. Recipients of the task who can act on the task.
  3. User Interface which will be shown in ‘My Inbox’.
  4. Other properties like priority, due date, etc.

Name, Documentation & Display Texts

 

The following properties are available in the General tab:

Name:

You can maintain any text here that gives a brief about the user task. Note that this text will be displayed in the user task activity of the workflow model and in My Inbox as page title. (Tip: keep it precise and brief).

Description:

In this optional field, you can maintain the detailed description about the user task – what it is meant for and what is the desired outcome of this task. If you had used a collaborative modelling tool to define the workflow (example, SAP Power Designer, SAP EA Designer, etc), you will already have the content for Name & Description.

Show in Inbox Workflow Log:

When you enable this checkbox, the activity log corresponding to the user task (for example, user task is created, user task is completed, etc.) will be shown for the end users in My Inbox who is responsible for user tasks in that workflow. The end users could click on ‘Show Log’ button in My Inbox to view the all user tasks performed so far for that workflow instance. They also get to know who has performed them and when it was completed.

By default, every user task is shown in the workflow log. But, if the user task has sensitive information that it should not be shown to recipients of further user tasks of the workflow, then you can uncheck the same. This will hide the user task appearing in the workflow log.

Note: By unchecking the above property, you can prevent the task recipients to view the workflow log for the respective user task, but you cannot prevent from showing it in the ‘Monitor Workflow’ app (used by the Workflow Admin).

The following properties are available in the DETAILS tab of user task Properties:

Display Texts

Subject

You maintain the title of the task in subject and this text is displayed in My Inbox. Keep it precise and make sure it contains attributes to uniquely identify user tasks, for example the Business Key. You could combine static text together with expressions to dynamically form the text based on the workflow context.

Example for bad subject text is ‘Approve Leave Request’. When this task is displayed in My Inbox, the manager needs to go into the details to identify who created the request.

Good subject text uses combination of static and dynamic content. ‘Approve Leave Request for ${context.employee.firstName} ${context.employee.lastName}’. This will be transformed to ‘Approve Leave Request for John Doe’ (assuming the workflow context contains employee information).

Description

Here, you can provide detailed description on what the task recipient need to perform. This description can be shown in My Inbox to the end users (refer to the help documentation on how to enable description in task UI). You can use expressions to provide dynamic texts from the workflow context.

Task Recipients

Here you provide one or more users who should process the user task. Task recipients could either be a single user ID or multiple user IDs, one or more user groups (use comma separated values for multiple user id/group) or you could also dynamically determine them using a SAP Cloud Platform Business Rules (and set it in the workflow context) or a combination of the above.

In the image below, I have used a static user (P194….) and a list of users determined by a SAP Cloud Platform Business Rule and made available in the workflow context.

Note: You can assign a maximum number of 100 users or groups as recipients to a user task.

User Interface

To assign a custom task UI to the user task, first import the SAP UI5 application project to the WebIDE workspace (you can do it without importing the application, but assigning user interface is very simple if you have the application in the workspace).

  1. Click the Select button
  2. Choose the project name from the drop down (all the projects available in your webIDE workspace will be listed here)
  3. Choose the SAPUI5 component path from the dropdown

For more information, refer to the help document which also explains the steps to manually provide the custom task UI details.

Other Properties

Priority

You can set priority of the user tasks depending on how critical the task is. By default, the priority is set as medium, but you can set either of Low, Medium, High or Very High as priority.

When do you need this – Based on the priority, the end user can filter or sort the tasks in My Inbox. This will help the user to focus on, for example, Very High priority tasks especially when there are huge list of tasks to work on.

Due Date

If you need to maintain the duration by when the task is due, you need to select the checkbox. You could either provide a static value or an expression (as per ISO 8601) for the duration by when the task will be due.

Static Value: Static value comprises of the value and its unit, for example 25 Minutes, 2 Days, 1 Month, etc.

Expression: The expression accepts duration in ISO 8601 format. As per the standard, the duration is represented in the format P[n]Y[n]M[n]DT[n]H[n]M[n]S.

P is the duration designator for period, Y for the year, M for month, D for days & T for time. The H, M and S followed by T represents hour, minutes and seconds respectively. For example, P2Y represents a duration of 2 years. Similarly, P1M3D represents 1 month and 3 days while P3DT1H30M represents duration of 3 days 1 hour and 30 minutes. (Note that all designators other than P are optional, but atleast one designator other than P should be present. For example, P is invalid, while P1D is a valid duration).

Consider the following points before setting an expression for due date:

  • The smallest units which the duration specification supports are minutes.
  • The “Week” unit (“W”) is not supported, but instead you can use the “Days” (“D”) to achieve the same result. P1W is same as P7D.
  • The duration specification supports integers only – You cannot have an expression like P1.5M but the same can be achieved with the expression P1M15D.

For the due date you could either give a static ISO 8061 standard value (like P1DT6H) or provide a workflow context expression which will evaluate to the ISO 8061 standard.

The due date information and priority are shown in My Inbox to the task recipients for them to choose the right task to work on. They can use the filter and sort options in My Inbox to work on, for example, overdue very high priority tasks.

Note: The due date, priority, recipients, subject, description, etc of an active task can be modified using the SAP Cloud Platform Workflow REST APIs.

Please keep in mind that not all the features explained here might be needed for your specific use case. But once you are aware of all the features available, it will be very easy to map & apply them for your use case.

Assigned Tags

      18 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hello Sreenivas,

      Thank you for such an informative post. I have a question regarding recipients in the user task.

      Can we add external email id's such as gmail or yahoo account id's as recipient apart from SAP user ID? If yes, could you please tell the steps to be implemented.

      Thank you,
      Varsha.

       

      Author's profile photo Archana Shukla
      Archana Shukla

      Hello Varsha,

      The users that can be configured in user tasks of workflow can either be SAP Cloud Platform members or IDP users associated with your account. If your user in SAP Cloud Platform or IDP is registered with gmail/yahoo account then you can use the same. You can read more about them in IDP official guide or how-to register to SAP Cloud Platform guides.

      Regards,
      Archana

      Author's profile photo Former Member
      Former Member

      Hello Archana,

      I wonder know if SAP Cloud Platform trial user can send message to other users such as you have mentioned in this comment?

      Best regards,

      Joy Lee

      Author's profile photo Archana Shukla
      Archana Shukla

      Yes, trial account are not meant to be shared. It is to do self development and learning.

      Regards,
      Archana

      Author's profile photo Former Member
      Former Member

      Thanks for your replying.

      Best Regards,

      Joy Lee

      Author's profile photo Sai Peddaiahgari
      Sai Peddaiahgari

      Hi Archana,

      Is there any possibility of giving e-mail id as a recipient in user task instead of I or D or P Numbers ? Being the email id is associated with my account ?

      If so, please let me know the steps to implement it?

      Thanks
      Sai Peddaiahgari.

      Author's profile photo Sankara Bhatta
      Sankara Bhatta

      Hi Sreenivas,

       

      I am trying to trigger SCP workflow from an on premise system. I created a ABAP report with below code. The first part getting CSRF token works fine, but the second part for creating the instance fails with error ". is this a code error? or some configuration on SCP side?

      HTTP Status 403 – Forbidden

      ABAP code

      *&---------------------------------------------------------------------*
      *& Report Z_TRIGGER_SCP_WORFKLOW
      *&---------------------------------------------------------------------*
      *&
      *&---------------------------------------------------------------------*
      REPORT Z_TRIGGER_SCP_WORFKLOW.
      
      DATA: lo_http_client TYPE REF TO if_http_client.
      DATA: response TYPE string.
      
      "create HTTP client by url
      "API endpoint for API sandbox
      CALL METHOD cl_http_client=>create_by_url
        EXPORTING
          url                = 'https://bpmworkflowruntimea2d6007ea-a0dcb0a14.hana.ondemand.com/workflow-service/rest/v1/xsrf-token'
      
        IMPORTING
          client             = lo_http_client
        EXCEPTIONS
          argument_not_found = 1
          plugin_not_active  = 2
          internal_error     = 3
          OTHERS             = 4.
      
      
      
      IF sy-subrc <> 0.
        "error handling
      ENDIF.
      
      "setting request method
      lo_http_client->request->set_method('GET').
      
      "adding headers
      lo_http_client->request->set_header_field( name = 'X-CSRF-Token' value = 'Fetch' ).
      lo_http_client->request->set_header_field( name = 'Content-Type' value = 'application/json' ).
      lo_http_client->request->set_header_field( name = 'Accept' value = 'application/json' ).
      lo_http_client->request->set_header_field( name = 'Authorization' value = 'Basic UDE5NDI5MTg2MDY6U2Fua2FyQGhhbmE=' ).
      "API Key for API Sandbox
      *lo_http_client->request->set_header_field( name = 'APIKey' value = 'Vw0jBxyASfBvPz8NRDGFbEpcTKxizWKr' ).
      
      
      "Available Security Schemes for productive API Endpoints
      "Basic Authentication, OAuth 2.0
      
      "Basic Auth : provide username:password in Base64 encoded in Authorization header
      "lo_http_client->request->set_header_field( name = 'Authorization' value = 'Basic <Base64 encoded value>' ).
      
      CALL METHOD lo_http_client->send
        EXCEPTIONS
          http_communication_failure = 1
          http_invalid_state         = 2
          http_processing_failed     = 3
          http_invalid_timeout       = 4
          OTHERS                     = 5.
      
      IF sy-subrc = 0.
        CALL METHOD lo_http_client->receive
          EXCEPTIONS
            http_communication_failure = 1
            http_invalid_state         = 2
            http_processing_failed     = 3
            OTHERS                     = 5.
      ENDIF.
      
      IF sy-subrc <> 0.
        "error handling
      ENDIF.
      data: lt_fields type TIHTTPNVP.
      data(lo_response) = lo_http_client->response.
      
      lo_response->IF_HTTP_ENTITY~GET_HEADER_FIELDS( CHANGING fields = lt_fields ).
      
      *cl_demo_output=>display( lt_fields ).
      
      data(ls_fields) = lt_fields[ name = 'x-csrf-token' ].
      data(lv_csrf) = ls_fields-value.
      
      clear: lo_http_client.
      
      CALL METHOD cl_http_client=>create_by_url
        EXPORTING
          url                = 'https://bpmworkflowruntimea2d6007ea-a0dcb0a14.hana.ondemand.com/workflow-service/rest/v1/workflow-instances'
      
        IMPORTING
          client             = lo_http_client
        EXCEPTIONS
          argument_not_found = 1
          plugin_not_active  = 2
          internal_error     = 3
          OTHERS             = 4.
      
      
      
      IF sy-subrc <> 0.
        "error handling
      ENDIF.
      
      "setting request method
      lo_http_client->request->set_method('POST').
      
      "adding headers
      lo_http_client->request->set_header_field( name = 'X-CSRF-Token' value = lv_csrf ).
      lo_http_client->request->set_header_field( name = 'Content-Type' value = 'application/json' ).
      lo_http_client->request->set_header_field( name = 'Accept' value = 'application/json' ).
      lo_http_client->request->set_header_field( name = 'Authorization' value = 'Basic UDE5NDI5MTg2MDY6U2Fua2FyQGhhbmE=' ).
      
      
      
      CONCATENATE '{"definitionId": "myworkflowtest",'
        '"context": { "PreqItem": "00010", "Material": "000000000000000011",'
        '"Plant": 5000, "DelivDate": 25082018,"PrNumber": " " }}' into data(lv_json).
      
      
      
      CALL METHOD lo_http_client->request->set_cdata
        EXPORTING
          data = lv_json.
      
      CALL METHOD lo_http_client->send
        EXCEPTIONS
          http_communication_failure = 1
          http_invalid_state         = 2
          http_processing_failed     = 3
          http_invalid_timeout       = 4
          OTHERS                     = 5.
      
      IF sy-subrc = 0.
        CALL METHOD lo_http_client->receive
          EXCEPTIONS
            http_communication_failure = 1
            http_invalid_state         = 2
            http_processing_failed     = 3
            OTHERS                     = 5.
      ENDIF.
      
      IF sy-subrc <> 0.
        "error handling
      ENDIF.
      
      response = lo_http_client->response->get_cdata( ).
      
      cl_demo_output=>display( response ).
      Author's profile photo Seshadri Sreenivas Ramanarayanan
      Seshadri Sreenivas Ramanarayanan
      Blog Post Author

      Hi Sankar,

      Since the query is not related to the content of the blog, I would suggest you post the question in the forum.

      Nevertheless, the issue I see in your code is you clear the lo_http_client after getting the XSRF token and create a new instance of thelo_http_client. Since the token is valid for the particular session (lifetime of lo_http_client), you are getting the 403 error. My suggestion is to use the same lo_http_client but change the URL to create a workflow instance.

      Regards, Sesh

      Author's profile photo Sankara Bhatta
      Sankara Bhatta

      Hi Sesh,

       

      Thanks for the reply. I have removed the clear statement but still getting the same error. Based on your suggestion i have created a question is SAP cloud workflow community. below is the link. could you help me here?

      https://answers.sap.com/questions/615947/trigger-scp-from-abap-program.html

       

      Author's profile photo Gabriel Ash
      Gabriel Ash

      Why is that my inbox is still empty when i see my workflow is running. even i put myself as the processor. no luck

      Author's profile photo Seshadri Sreenivas Ramanarayanan
      Seshadri Sreenivas Ramanarayanan
      Blog Post Author

      SAP Cloud Platform MyInbox could be 'empty' for two main reasons. You either don't have the roles to access the task  or you don't have task assisgned. Can you verify if you have maintained your user id in capitals?

      Can you use the workflow monitor (workflow instance) app, look at the task instance, check the user assignment and share the screen capture here?

      Author's profile photo Gabriel Ash
      Gabriel Ash

      Hey thanks it worked. I realized it was the way i handled my user name in workflow. rectified . thanks

      Author's profile photo Gabriel Ash
      Gabriel Ash

      please find the screenshots inbox is still empty and cannot find the reason yet

       

      So these are the roles available

      WorkflowMessageSender

      Workflow Developer

      WorkflowAdmin

      Workflow Participant

      WorkflowContextViewer

      WorkFlowTenantOperator

      WorkflowCOntextAdmin

      WorkflowInitiator

      WorkflowViewer

      and also individuals user is also assigned with my userid. in the work flow both recipient and initiator is me

      Author's profile photo Seshadri Sreenivas Ramanarayanan
      Seshadri Sreenivas Ramanarayanan
      Blog Post Author

      I see that the recipient starts with a small 's'. Can you change that to capital 'S' in the workflow model, save,  deploy and start a new instance. You should see a task in your Inbox.

      Author's profile photo Gabriel Ash
      Gabriel Ash

      Yes it worked. i was working with the same instance even making the change of capital case in workflow. thanks a lot Sreenivas

       

      Author's profile photo Seshadri Sreenivas Ramanarayanan
      Seshadri Sreenivas Ramanarayanan
      Blog Post Author

      Great, no problem 🙂

      Author's profile photo Gabriel Ash
      Gabriel Ash

      Lessons learnt. If you encounter any issues at deployment or any in the workflows the first thing u need to look at typos and spaces .if you solve it then no issues. LOL. 

      Author's profile photo Roshni Srivastava
      Roshni Srivastava

      Hi Sreenivas,

      Thanks for sharing this informative blog. I have one query if I have to set priority in user task based on the incoming payload(context) is there any way to do so.