Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Copy value from single user picker and multi user picker to multi user picker

Dmitry P March 10, 2019

I have an issue with copying single user picker value and multi user picker to multi user picker value.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.label.LabelManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.event.type.EventDispatchOption

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def cfMgr = ComponentAccessor.getCustomFieldManager()
def changeHolder = new DefaultIssueChangeHolder()

def cfMultiSelectUser = cfMgr.getCustomFieldObject("customfield_19221") //multi
def cfMultiSelectUserValue = issue.getCustomFieldValue(cfMultiSelectUser)

def cfSingleSelectUser3 = cfMgr.getCustomFieldObject("customfield_19224") //single
def cfSingleSelectUserValue3 = issue.getCustomFieldValue(cfSingleSelectUser3)

def cfMultiSelectUser2 = cfMgr.getCustomFieldObject("customfield_19223")
def cfMultiSelectUserValue2 = issue.getCustomFieldValue(cfMultiSelectUser2)

cfMultiSelectUserValue2.push(currentUser)
cfMultiSelectUser2.updateValue(null, issue, new ModifiedValue(cfMultiSelectUserValue2, cfMultiSelectUserValue, cfSingleSelectUserValue3),changeHolder)


it is working, but when trying to addition single user picker as the copy field always value is just empty.


1 answer

0 votes
Kristian Walker _Adaptavist_
Community Champion
March 11, 2019

Hi Dmitry,

Can I please ask if you are using ScriptRunner for Jira Cloud as you have marked your question as Jira Cloud but have included code for Jira Server which is not valid inside of Jira Cloud.

If you require assistance with this question relating to Jira server, you should remove the tag for Jira Cloud and add in the tag of com.onresolve.jira.groovy.groovyrunner so that other users of the Server version can see this question and can advise on it. 

 

Regards,

Kristian

Suggest an answer

Log in or Sign up to answer