How to execute workflow transition with initiator user

Originally asked by Duc on 08 January 2022 (original question)


Hi,

I would like to ask if it’s possible to execute the status mapping with the user who has initiated it. The status mapping is working but the executer of the transitions is the user “Exalate”. If I execute a transition in project A I also want to be the executer of this transition in project B.

This is my current configuration (incoming sync):

def statusMap = [
  
       // "remote status name" (CASD): "local status name" (ITS)
         "Waiting for support" : "Assigned",
         "Assigned" : "Assigned",
         "In Progress" : "In Progress",
         "Solution not accepted" : "Solution not accepted",
         "Waiting for Customer" : "Waiting for Customer",
         "Waiting for Internal" : "Waiting for Internal",
         "Waiting for External" : "Waiting for External",
         "Solved for end user" : "Solved for end user",
         "Closed" : "Closed"
   ]
def remoteStatusName = replica.status.name
issue.setStatus(statusMap[remoteStatusName] ?: remoteStatusName)

Hope you can help me.

Thanks a lot!


Answer by Ariel Aguilar on 11 January 2022

Hi Duc,
Would it work if the assignee is used as reference? You may try:

def assignee = nodeHelper.getUserByEmail(replica.assignee?.email)
if (replica.status.name = "Closed"){
  workflowHelper.transition(issue, "Closed", assignee)
	}else if (replica.status.name = "Solved for end user"){ 
 	 workflowHelper.transition(issue, "Solved for end user", assignee)
	}else if (replica.status.name = "Waiting for Internal"){ 
  	workflowHelper.transition(issue, "Waiting for Internal", assignee)
	}else if (replica.status.name = "Waiting for External"){ 
  	workflowHelper.transition(issue, "Waiting for External", assignee)
	}else if (replica.status.name = "Waiting for Customer"){ 
  	workflowHelper.transition(issue, "Waiting for Customer", assignee)
	}else if (replica.status.name = "Solution not accepted"){ 
  	workflowHelper.transition(issue, "Solution not accepted", assignee)
	}else if (replica.status.name = "In Progress"){ 
  	workflowHelper.transition(issue, "In Progress", assignee)
	}else if (replica.status.name = "Assigned" || replica.status.name = "Waiting for support"){ 
  	workflowHelper.transition(issue, "Assigned", assignee)
	}
}

Kind regards,

Ariel