In an OR step for a workflow, I need to know the initiator user to decide if the route should be true or false, based on user roles.
In a workflow step, I can do this:
public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap args) throws WorkflowException { … UserManager userManager = AccessControlUtil.getUserManager(workflowSession.getSession()); Authorizable initiator = userManager.getAuthorizable(workItem.getWorkflow().getInitiator()); … }
Note: in a workflow step, if I do ‘workflowSession.getUser()’ I always get ‘admin’ user, and it’s not what I want.
But, as stated in [1] by David McMahon, in an OR step for a workflow, only the workflowData, jcrSession, and workflowSession objects are available to be used within the check() function (not the workItem).
How can I get the initiator user in a workflow route?
Solved! Go to Solution.
Instead of args.put can you try workflowData.getMetaDataMap().put( "initiator", workItem.getWorkflow().getInitiator()) ;
Did you try to add a process step earlier in the model that set the metadata with the initiator ? That would probably the easiest to solve as then in your or-split you can access the metadata via the workflowData
Views
Replies
Total Likes
Thank you tygeBSL. I've tried this in the first workflow step:
public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap args) throws WorkflowException { ... args.put("initiator", workItem.getWorkflow().getInitiator()); ... }
But in route code I can't write the initiator to the log:
if(workflowData.getMetaDataMap().containsKey("initiator")){ String initiator = (String)workflowData.getMetaDataMap().get("initiator"); log.info("initiator: " + initiator); }
containsKey("initiator") returns false. Am I forgetting something?
Thank you very much!
Views
Replies
Total Likes
Instead of args.put can you try workflowData.getMetaDataMap().put( "initiator", workItem.getWorkflow().getInitiator()) ;
Perfect! Now it works!
Thank you very much! :-)
Views
Replies
Total Likes
Views
Likes
Replies