How to Fetch Component/s values using scriptrunner

Deleted user March 6, 2018

I am trying to fetch a value from Component/s field using scriptrunner, but unable to find any value.

2 answers

2 votes
Mirek
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 6, 2018

Maybe you can try this?

issue.getComponentObjects().getAt(0)?.getName()

Best Regards,

Mirek

 

Deleted user March 6, 2018

Hi Mirek,

I tried this snippet too. Syntax check was successful, but  output was blank. 

Sugandha April 29, 2019

@Mirek , I tried your solution, it is working but it is only showing output for the very first component value, not all the values present in component.

 

Suppose I have components = a,b,c

so when I execute issue.getComponentObjects().getAt(0)?.getName()

the output is a

Is there any way so that we can pull all the component values?

1 vote
Gezim Shehu [Communardo]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 6, 2018

Try simply

 

issue.components.name

Deleted user March 6, 2018

Hi Gezium, thanks for the snippet, but this didn't help me.

Gezim Shehu [Communardo]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 6, 2018

Where are you running it. 

I just tried in script console (JIRA 7.3) and worked.

 

Maybe you are running it on a post function?

Deleted user March 6, 2018

I am trying in JIRA 7.2.2 Scriptrunner, i want to fetch value which is present in Component/s and display in scripted field.

Gezim Shehu [Communardo]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 6, 2018

Ok, I added it in a scripted field, it originally shows a typing validation error, but bypassing and saving works.

 

Even just by preview it shows the component/s, Also in screen it's shown as a list []

Deleted user March 6, 2018

Can you please share the whole code in here??

Like Fabian Krehnke likes this
Gezim Shehu [Communardo]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 6, 2018

it's just that line.

Like Junior Lobo likes this
Sugandha April 29, 2019

@Gezim Shehu [Communardo] this works for me.

I am trying this in script console , it is giving a red mark but in output it is giving me all component values

Stefan L_ April 26, 2024

Thx mate - it is as simple :-)

 

// Console 
    def componentField = Issues.getByKey('KEY-123').components.name

// Shows a list of all Components
// I can now check if my component is part with


componentField.contains("My Value")

// Output "true" when Component is part of the ticket

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events