During a workflow transition I'm attempting to copy the value of the current assignee into a single user custom field, then separately add the current user (the person clicking the button that does the transition) into another single user customfield.
Please can someone help me write the Groovy script for Scriptrunner?
For your requirement, you can try out something like this:-
def issue = issue as MutableIssue
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def customFieldManager = ComponentAccessor.customFieldManager
def assignee = issue.assignee
def userPicker = customFieldManager.getCustomFieldObjectsByName("User Picker")
def currentUser = customFieldManager.getCustomFieldObjectsByName("Current User")
Below are a few test screens for your reference:-
You will need to use the Custom Script option in the Post-Function as shown below:-
1) First when the ticket is created only basic info is entered and the assignee is selected as shown below:-
2) Once the ticket has been created, only the Report and Assignee are visible as shown below:-
3) Next, when the issue is transitioned to In Progress, the additional single user picker fields are displayed as shown below:-
I hope this helps to answer your question. :)
Thank you and Kind Regards,
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events