Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

ScriptRunner Cloud: Set Issue Component

Benjamin Dombrowsky _D4Digital_ November 20, 2023

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 Champion
November 21, 2023

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

Benjamin Dombrowsky _D4Digital_ November 21, 2023

Thank you, your script works! :-)

Kristian Walker _Adaptavist_
Community Champion
November 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