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,739
Community Members
 
Community Events
185
Community Groups

Edit Multi User Picker FIeld

Hi community, 

I am using Scriptrunner Cloud to attempt to retrieve the members of a Jira group (group1), and write those users to a multi user picker custom field.

  • I have a call to retrieve the group members' account IDs (working)
  • Using collect to format the list of account IDs to make it API call ready (?)
  • The edit/put call is working when values are manually typed in (working)
  • Error when executing the script -- "errors":{"customfield_xxxxx":"expected Object"}}
  • I suspect that my issue is with how I am formatting the list of account IDs, but I do not know of any alternatives.

---

def gusers = get("/rest/api/3/group/member?groupname=group1")
.header("Content-Type", "application/json")
.asObject(Map)
def accountdetails = gusers.body.values as List<Map>
def accountids = accountdetails.accountId
def modaccountids = accountids.collect{'["id":' + '"' + it + '"]'}

print(modaccountids)

//api call
put("/rest/api/3/issue/ABC-123")
.header("Content-Type", "application/json")
.queryString("overrideScreenSecurity", Boolean.TRUE)
.body([
"fields": [
"customfield_xxxxx": [
modaccountids
]
]
])
.asString()

 

Any help would be greatly appreciated!

1 answer

1 accepted

1 vote
Answer accepted

Hi community, 

After a few more cycles, I was able to resolve this issue. In my original post, I thought my issue was related to the way formatting the list of account IDs, and that did turn out to indeed be the issue. Here is how I resolved it...

 

Original: def modaccountids = accountids.collect{'["id":' + '"' + it + '"]'}

Updated: def idList = accountids.collect { item -> ["id": item] } 

 

Hopefully this can help the community at some point in the future. Cheers!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events