Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,559,298
Community Members
 
Community Events
184
Community Groups

Load multi-user custom field from Project Role values

I have tried it all!  I have scoured the interwebs to no avail.  I have a project role consisting of multiple users and I need to load those users into a multi-user custom field. The most straightforward way it seems is from a Jira Group instead of project roles, I am good with either.  This is the code I have found for the group into custom field.

 

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder

def groupManager = ComponentAccessor.getGroupManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()

def myJiraGroup = groupManager.getGroup("Jira Group name") // get the group
def usersInGroup = groupManager.getUsersInGroup(myJiraGroup) // get the users in that group
def myCustomField = customFieldManager.getCustomFieldObjectsByName("Custom multi-user field")
myCustomField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(myCustomField), usersInGroup), new DefaultIssueChangeHolder()) // update myCustomField with users

 

It throws an error "No signature of method:" but the details get cut off before I can read what parameter is hosed.

 

TIA

1 answer

1 accepted

1 vote
Answer accepted
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jul 07, 2021

Your issue might be just with the "def myCustomField" line.

If you look carefully, you will see that you are calling "getCustomFieldObjectsByName", the plural on "Objects" means that you can potentially get more than one custom field with this method. Even when you only have 1 custom field that matches that name, you will still get a collection or array of custom fields and you have to identify which item in the collection is the custom field you care about.

If you are 100% sure that you only have 1 custom field with that name, you can just get item 0 from the collection.

def myCustomField = customFieldManager.getCustomFieldObjectsByName("Custom multi-user field")[0]

Peter-Dave...is it possible to be so happy and so mad at the same time?  Because those 3 characters "[0]" just made me into a WINNER!  Next time you are in KC I owe you a beverage.  Thank you sir.  Consider your answer...ACCEPTED!  

Like Peter-Dave Sheehan likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events