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:-
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
def issue = issue as MutableIssue
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def customFieldManager = ComponentAccessor.customFieldManager
def assignee = issue.assignee
def userPicker = customFieldManager.getCustomFieldObjectsByName("User Picker")[0]
def currentUser = customFieldManager.getCustomFieldObjectsByName("Current User")[0]
issue.setCustomFieldValue(userPicker, assignee)
issue.setCustomFieldValue(currentUser, loggedInUser)
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,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
only tweak was the variable name for issue to iss as it confuses with the other 'issue' but otherwise spot on!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.