Forums

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

Jira Automation - Advanced Field Editing - Looping on List Variable gen from match() fails

Guy Derriman
Contributor
September 17, 2023

Im sure this is a bug but cant find where to log it.
The scenario I'm trying to create is to copy all labels matching "AssetMaintenance_*" from an Epic to it's child issues. 

If I loop on children issues then 
Edit Issue fields - advanced field editing
it works


{
"update": {
"labels": [{{#issue.parent.labels.match("(AssetMaintenance_[^,]*)")}}{"add": "{{.}}"}{{^last}},{{/}}{{/}}]
}
}

However if I use the same statement and assign it to a variable it fails 

Create variable 

parentLabelList = issue.labels.match("(AssetMaintenance_[^,]*)")

Then loop on children issues then 
Edit Issue fields - advanced field editing
it fails

{
"update": {
"labels": [{{#parentLabelList}}{"add": "{{.}}"}{{^last}},{{/}}{{/}}]
}
}

ERROR: Error while parsing additional fields. Not valid JSON.

the problem is I have to do an if condition and copy and paste the logic to check the count before looping. So I have to copy the complex regex twice :(

1 answer

1 accepted

1 vote
Answer accepted
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.
September 18, 2023

Hi @Guy Derriman -- Welcome to the Atlassian Community!

Would you please post images of:

  • your complete rule,
  • including the details of the Create Variable, condition, the issue edit, and 
  • of the full audit log details showing a rule execution

Those will provide context to help explain this symptom.  Thanks!

Until we see those, I suspect the problem is you are missing a split on your created variable before you try to iterate over it in the advanced edit.  The source labels were a list, but the variable is just text.

{
"update": {
"labels": [{{#parentLabelList.split(",")}}{"add": "{{.}}"}{{^last}},{{/}}{{/}}]
}
}

Seeing the complete information will confirm this.

Kind regards,
Bill

Guy Derriman
Contributor
September 19, 2023

This was it Bill, thanks so much for your time and effort to point it out.

Like Bill Sheboy likes this
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.
September 20, 2023

Awesome!  I am glad to learn it is working.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events