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: 
Venugopal
Product and Topic Expert
Product and Topic Expert
0 Kudos

Accessing Task Instance details from Process Context

Prerequisites

1. You are modeling Processes using Process Builder , the no-code process modeling tool.

2. SAPUI5 as your approval or task UIs.

Enhance SAPUI5 Task UI5 component

SAP Build Process Automation supports SAPUI5 as the approval / task UIs. SAP Build Process Automation provides SAPUI5 component generation as Process Start or Task UIs.  The input/output mapping of an approval form is managed through the manifest.json file of your SAPUI5 component.

Update sap.bpa.task in manifest.json

Enhance the output mapping json schema of your Approval form. Enhance your outputs json object of your  sap.bpa.task name space with additional task instance related info. for eg. TaskInfo is the json object with task instance information. In this example Task instance id, approver id and approver decision are added so that these attributes can be accessed from the process context after completion of the task instance by the approver.

 

     "sap.bpa.task": {
        "_version": "1.0.0",
        "outcomes": [
            {
                "id": "approve",
                "label": "Allow"
            },
            {
                "id": "reject",
                "label": "Deny"
            }
        ],
        "category": "approval",
        "outputs": {
            "$schema": "http://json-schema.org/draft-07/schema",
            "title": "output",
            "type": "object",
            "required": [],
            "properties": {
                "Comments": {
                    "type": "string",
                    "title": "Comment",
                    "description": "Description for Textfield"
                },
                "TaskInfo": {
                    "type": "object",
                    "description": "Task Instance details",
                    "properties": {
                        "ID": {
                            "type": "string",
                            "description": "Task Instance id",
                            "title": "Task Instance ID"
                        },
                        "Approver": {
                            "type": "string",
                            "description": "Approver completed the task",
                            "title": "Approver"
                        },
                        "Decision": {
                            "type": "string",
                            "description": "Approver Decision",
                            "title": "Decision"
                        }
                    }
                }
            }
        }

 

Update SAPUI5 Task completion event handler

Task instances uses the patch API to complete and provide output mapping to the process context.Enhance the output mapping of the Task instance as given below. The TaskInfo json object contains attributes like Task Instance ID, approver name and approver decision.

 

 var data = {
            status: "COMPLETED",
            decision: "approve",
            context: {
              Comments: "approved",
              TaskInfo:{
                ID: this.getComponentData().startupParameters.taskModel.InstanceID,
                Approver:sap.ushell.Container.getService("UserInfo").getUser().getEmail(),
                Decision:"Approved"
             },
                                   
         }

 

 Build and deploy your SAPUI5 component.

Process Build Output Mapping

Import SAPUI5 component as a form in SAP Build Process Automation and add this component as an approval form.

TaskInstanceOuput.png