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

ScriptRunner Cloud: Set Issue Component

Edited

Hi guys, 

I'm currently trying to set a component to an issue via ScriptRunner and am (probably) failing because of the correct syntax.

Can someone help me? Thanks in advance!

 

Update Code Snipped:

// Update the issue
def resultIssueUpdate = put("/rest/api/2/issue/${issue.key}")
//.queryString("overrideScreenSecurity", Boolean.TRUE)
.header('Content-Type', 'application/json')
.body([
fields:[
components:[id: "10009"]
]
])
.asString()

 Result: 

PUT request to /rest/api/2/issue/FIBU-5098 returned an error code: status: 400 - Bad Request
{"errorMessages":[],"errors":{"components":"The list contains an invalid value"}}

 

Best regards

Benjamin

1 answer

1 accepted

1 vote
Answer accepted
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 21, 2023 • edited

Hi Benjamin,

I can confirm that to set a component, you can use the example located here.

Using this, you will see that the components field needs to be an array where each element is an array which has the name and value of the component.

This example can be run on the script console to see how it works and then moved into other scripts, such as post function or listener scripts, to help achieve your requirement.

I hope this answer helps.

Regards,

Kristian

Thank you, your script works! :-)

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 21, 2023

Hi Benjamin,

I am glad it helped.

Could I please ask you to accept the answer to mark it as correct for other users to find?

Regards,

Kristian

Suggest an answer

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

Atlassian Community Events