Not very familiar with groovy, but managed to get some things wroking. Unformtunately I have an issue with copying single user picker value to multi user picker value. Trying to do that for some time, but with no success so at the moment as workaround I'm just copying single to single.
Here is the current code for single to single copying, as a workarounf
def cfMultiUser1 = customFieldManager.getCustomFieldObjectByName(field);
def cfMultiUser1Value = issue.getCustomFieldValue(cfMultiUser1)
def cfMultiUser2Value = issue.getCustomFieldValue(cfMultiUser2)
cfMultiUser2.updateValue(null, issue, new ModifiedValue(cfMultiUser2Value, cfMultiUser1Value),changeHolder);
it is working, but when trying to use multi user picker as the destination field always get some issues, or the value is just empty.
I was trying to put the user from first filed into list but it doesn't work. I tried different solutions but all are invalid. One of them is:
users = new ArrayList<>();
cfMultiUser2.updateValue(null, issue, new ModifiedValue(cfMultiUser2Value, users),changeHolder);
I'm running jira v. 7.10.2
I will appreciate any suggestions.
So you said you want to add value from single user picket to multi user picker.
Here is a working code, in this example i took the current logged in user and added it to a multi select user picker field, but instead you can take any customfield with a single user picker value, it's the same.
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
def changeHolder = new DefaultIssueChangeHolder()
def cfMultiSelectUser = customFieldManager.getCustomFieldObjectByName("Testers List")
def cfMultiSelectUserValue = issue.getCustomFieldValue(cfMultiSelectUser)
cfMultiSelectUser.updateValue(null, issue, new ModifiedValue(cfMultiSelectUserValue, cfMultiSelectUserValue),changeHolder);
Jira 7.3.7 it should be the same.
the "push" is for the multi user picker field value, which is an ArrayList.
It doesn't matter what is the Jira version, it's coding, ArrayList have push.
If you are getting an error on the "push" than you did not use my code right.
Check again my code and your changes in it.
Basically, all you need to change in my code is the "Testers List", change it with your multi select user picker field name.
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