Forums

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

ScriptRunner - get component name to post-function

anttipolla
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 20, 2018

I'm trying to set up a post-function that creates sub-tasks when the component is something specific. I'm finding some examples of figuring out the project lead etc but not component name itself. Anyone have anything working they could share? :)

The goal would be to add this to the create -step. I was going along the lines of...

def components = issue.getComponents()
cfValues['Task Type']?.value == 'Definition' && issue.projectObject.key in ["TEST"] && components.contains('W_Migration')

But this obviously doesn't work. It validates in ScriptRunner but nothing happens in transition (either in create or anywhere else).

Any assistance is greatly appreciated :)

2 answers

1 accepted

3 votes
Answer accepted
Tom Lister
Community Champion
November 20, 2018

Hi @anttipolla

try

def components = issue.components.toList()
components?.name.contains('blah')
anttipolla
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 20, 2018

Awesome! Thank you. I tried a similar one before but without the '?'. Maybe something else was different as well. In any case, this worked.

Like # people like this
Merve Nur Bas
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 24, 2020

Thanks you guys!!

Like # people like this
0 votes
Valerie Christine Knapp
Contributor
September 24, 2020

Hi everyone, I have been trying to figure out how to do this for about 2 weeks and had nearly given up hope but I just found that this solution works for me. Thanks so much!

Suggest an answer

Log in or Sign up to answer