Changing Work-item Initiator in a Workflow.
Usually, for a workflow with multiple steps in Approval process, the Work item initiator is the user who processed the previous step/ created the current step and sometimes, technically it is shown as “WF-BATCH” which is technical workflow system user.
I came across this situation where my client wants to see the User who triggered/initiated the workflow in his FIORI MY-INBOX, instead of the user who created the current step ( i.e, who processed previous step/ Work-Item initiator ) which in my case was being shown as “WF-BATCH”.
I have found two approaches for this.
- Changing the Workflow user using an update statement.
- Providing the Username in the Dialogue step of the of the Workflow while creating the workflow.
Approach 1: Changing the Workflow user using an update statement
This approach can be used if your workflow and its steps are processed programmatically.
Table SWWWIHEAD stores the Header details of all types of Work items. The field ‘WI_CRUSER’ stores the Name of the user who created the Work Item.
Updating the field WI_CRUSER in the Table SWWWIHEAD for the New Work item is one approach to solve this issue.
In this approach, I have triggered my WF manually using the below series of steps:
Step 1: Triggering the WF using the Below FM
Approval steps are also processed manually.
Step 2: FM: SAP_WAPI_GET_DEPENDENT_WIS is used to get the list of Work items under the main/Top Work-item. Looping them and obtaining the latest work-item.
Step 3: Using the FM: SAP_WAPI_WRITE_CONTAINER I am sending the user decision as Approved ( Refer Above screenshot for container values)
Step 4: I have processed my current step FM: SAP_WAPI_WORKITEM_COMPLETE.
Step 5: After processing the current step, I have obtained the newly generated Work Item and updated the table SWWWIHEAD table record for that Work item. (Field WI_CRUSER is updated for the newly generated Work item).
Make sure to store the Top WIID somewhere to perform approval steps further.
Approach 2: Providing the Username in the Dialogue step of the of the Workflow while creating the workflow
In the Workflow step, navigate to the properties tab. Property tab here, is basically a name-value pair where we provide the Property and its value.
Pass the value of the User name to the property “sap.bc.bmt.wfm.initiator” as shown below.
The container ‘_Workitem’ is a structure that stores the details of the Workflow on its first call:
After changing the Work-item Initiator using above procedures:
Using any of the above two approaches, One can change the Work-item initiator to the desired user.
Thanks for Reading.
Hope this post would be helpful.