Find users who completed previous user tasks in a workflow
Within a workflow script task that is executing, how can I inspect the previous tasks (specifically user tasks) to identify the user who completed it? I’m thinking it might have something to do with the workflowInstanceApi and/or the workflowTaskApi coupled with the execution ID but I really haven’t worked with these before. Appreciate any tips you can share…
mikemorrison
Posted 3 years ago · Edited 1 year ago·Last reply 1 year ago
4 comments
whithedelcarre
·1 year agoIf a Timer Intermediate Event is placed between the User Task and the Script Task, any subsequent actions in the workflow will be executed as if the "workflow user" is performing them. Consequently, when using userAPI.getCurrentUser(), it will return a user named 'Workflow.'
To avoid this, ensure there is no intermediary task between the User Task and the Script Task. By doing so, userAPI.getCurrentUser() will correctly return the actual user who completed the task.
After obtaining the user information, store it in execution.setVariable to retain the data for use in subsequent tasks within the workflow.
arthurburkhardt
·3 years ago · EditedYou can get the current user username in a workflow with the following method
A good way to figure out those things is to study existing workflow.
For example, in the OOTB Issue Management workflow, you can find such an example in the step “Accept review”
https://developer.collibra.com/workflows/workflow-documentation/Content/Workflows/OOTBWorkflows/IssueManagement/co_ootb-wf-issue-management-walk-through.htm
You can see in this image, that the workflow proposes the task to all business stewards of the issue domain, then assigns the role of reviewer to the user who first clicked on the “Accept Review” button.
arthurburkhardt
·3 years ago · EditedYou can get the current user username in a workflow with the following method
A good way to figure out those things is to study existing workflow.
For example, in the OOTB Issue Management workflow, you can find such an example in the step “Accept review”
https://developer.collibra.com/workflows/workflow-documentation/Content/Workflows/OOTBWorkflows/IssueManagement/co_ootb-wf-issue-management-walk-through.htm
You can see in this image, that the workflow proposes the task to all business stewards of the issue domain, then assigns the role of reviewer to the user who first clicked on the “Accept Review” button.
mikemorrison
OP3 years ago · EditedThanks Arthur! I was hoping you might see this.
You’re right, looking at the OOTB workflows is the way to go - that said, I haven’t rebuilt my eclipse environment for my current engagement and have been using the Workflow Designer. I could load all the OOTB workflows into it, but I understand that won’t be necessary soon.