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,463,390
Community Members
 
Community Events
176
Community Groups

Scriptrunner - Add multiple issues to a Multiple Issue Picker field using groovy

I am trying to programmatically update a ScriptRunner Multiple Issue Picker field using Groovy:

Here is my code:

def customFieldManager = ComponentAccessor.getComponent(CustomFieldManager);
def user = ComponentAccessor.getJiraAuthenticationContext().loggedInUser
def customField = customFieldManager.getCustomFieldObjectByName("Field Name")

Issue addOne = ComponentAccessor.issueManager.getIssueByCurrentKey("ID-123")
Issue addTwo = ComponentAccessor.issueManager.getIssueByCurrentKey("ID-321")

Collection<Issue> lists = [addOne, addTwo]
MutableIssue myIssue = issue
issue.setCustomFieldValue(customField,lists)

When I pass in a String, it adds the single issue to the Multiple Issue Picker field but I require to add multiple issues in one go. I have also tried using IssueInputParameters to update the field but have had no luck

Any ideas what I'm doing wrong?  

1 answer

I was looking for the same solution and found the following to work using the link

https://community.atlassian.com/t5/Adaptavist-questions/ScriptRunner-How-to-addCustomFieldValue-for-IssuePicker-with/qaq-p/1172311 

 

String[] issues = ["MSD-5", "MSD-6"]

.addCustomFieldValue(fieldId,issues)

 

Referenced

https://library.adaptavist.com/entity/update-the-value-of-custom-fields-through-the-script-console 

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events