Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How can I find if the parent has a label that ends with "_anything" and add the same to the subtasks

How on subtasks creation, I can find if the parent has a label that ends with "_anything" and add the same label to the created subtasks?

3 answers

1 vote
Sam Harding Atlassian Team Dec 05, 2021

Hi @Warda Basta

There is a way to do this using smart values. You can filter out the labels on the parent, using the endsWith() function, and set that list on the issue using the More Options Advanced Field Editing

Screen Shot 2021-12-06 at 10.54.52 am.png

The text being used here in the Additional fields section is

{
"fields": {
"labels": [
{{#issue.parent.labels}}{{#if(endsWith("anything"))}}"{{.}}",{{/}}{{/}}""
]
}
}

The above will set the labels on the sub-task to be the parent's labels with suffix of "anything", so if you have any other rules which also add labels on creation, they will overwrite/clash with each other. If you want to just add the labels, use

{
"update": {
"labels": [
{{#issue.parent.labels}}{{#if(endsWith("anything"))}}
{"add": "{{.}}"},
{{/}}{{/}}
{"add": ""}
]
}
}

 That will add the labels without removing any existing labels on the issue.

Cheers
Sam

Hello @Warda Basta ,

I created the below automation, which can copy the label value from parent to sub-task.

image.png

image.png

 

Thanks,

Kagithala Babu Anvesh

Darryl Lee Community Leader Nov 30, 2021

Oh snap. Automation has better Label searching than JQL. Nice work @KAGITHALA BABU ANVESH !!

Hi @Warda Basta 

What problem are you trying to solve doing this?  Why not just copy all of the labels to the children?

The use case you describe is not that simple, as you would need to parse each label to determine if it contains your text, such as "_anything".  In addition, what do you want to happen if that label is removed from the parent: do nothing or also remove it from the sub-tasks?

Trying this would require using the technique of advanced branching and a text search on the label using the function endsWith() and then another branch inside of that for sub-tasks...which is not possible at this time (nested branching).

Kind regards,
Bill

Darryl Lee Community Leader Nov 30, 2021

I was thinking the problem is that you can't do a native JQL search for labels with wildcards. (The solutions out there rely on the on-prem edition of ScriptRunner to get the issueFieldMatch function.)

If I'm understanding you, @Bill Sheboy your solution would require iterating through a bunch of issues and checking each label with endsWith(), right?

Hi, @Darryl Lee 

Yes.  I made a test rule which can find labels matching a pattern that way.  The challenge is then updating the sub-tasks.  What I did not try: using a regular expression instead to identify the labels (using conditional list processing), store that, and then iterate over the sub-tasks in a branch.

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
Community showcase
Published in Jira Software

👋 Looking for 15-20 volunteers to test Atlassian training content

Hi everyone! Are you interested in beta testing Atlassian University’s newest (unreleased!) training course? We’re looking for 15-20 volunteers to test our newest training course, Basic reporting...

559 views 20 25
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you