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

Warda Basta November 30, 2021

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
Atlassian Team members are employees working across the company in a wide variety of roles.
December 5, 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

1 vote
KAGITHALA BABU ANVESH
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.
November 30, 2021

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 30, 2021

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

0 votes
Bill Sheboy
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.
November 30, 2021

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 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?

Bill Sheboy
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.
November 30, 2021

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
AUG Leaders

Atlassian Community Events