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?
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
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.
Thanks,
Kagithala Babu Anvesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh snap. Automation has better Label searching than JQL. Nice work @KAGITHALA BABU ANVESH !!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.