Automation Rule Not Adding All Values to a Label Field

Bar Azgad November 18, 2024

I’m trying to create a Jira Automation rule where:
  1. I split a string field (customfield_10193) by commas using {{issue.customfield_10193.split(",")}}.
  2. I want to add each value from the split array to a label field (customfield_10164), which is configured as a label-type field.
The problem is that the rule doesn’t add all the values from the array to the label field. For example, if the string is:
Island,TEST,Test_Gilad,TestIt
Only TEST and TestIt are added, while Island and Test_Gilad are ignored.Here’s what I’ve done so far:
  • I’m using a “For each” loop to iterate over the array.
  • Each value is added conditionally to avoid duplicates.
Any advice on why the rule isn’t processing all values correctly or how to fix this issue?
Screenshot 2024-11-18 at 14.54.28.pngScreenshot 2024-11-18 at 14.54.42.png

1 answer

1 accepted

2 votes
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.
November 18, 2024

Hi @Bar Azgad -- Welcome to the Atlassian Community!

Automation rule branches which could be on more-than-one-thing are executed in parallel and asynchronously.  There is no guaranteed order of processing or even when the branch will complete, up until the last step of the entire rule.

What this means for the rule you show is the updates are colliding / walking over each other during the update processing, leading to unpredictable results.

 

The solution for your scenario is to add all of the labels with a single update using dynamically created JSON and a list iterator: 

Your branch logic seems to only be checking if the new label is not present before attempting the edit.  If that is ignored, the values could be updated even if they exist with this:

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

If you only want to perform the edit if the values are not currently present as labels, that would require using a dynamic regular expression and the removeAll() function to first eliminate any existing values.

 

Kind regards,
Bill

Bar Azgad November 19, 2024

Thank you! 

Bar Azgad November 19, 2024

Hi Bill,

Thank you for the detailed explanation and resources! Do you have additional recommendations or resources to learn more about Jira automation capabilities, especially for creating advanced rules like this one?

Kind regards,
Bar

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 19, 2024

Awesome; I am glad to learn that helped!

For learning more about automation rules, I recommend experimenting, reading, and collaborating...

  • When it doubt, try something to learn if it works, writing results to the audit log
  • Create a test project, or even a free test license site, and try things.  Experimenting in a free site reduces the impact for your production site.
  • When experimenting, it can be easy to quickly use up your monthly usage limits.  The workaround for that is to create test rules which only write to the audit log, rather than update issues.
  • There are lots of good examples "hidden" in the documentation, such as the one I provided for examples of using list iteration.  I recommend paging through all of them to look for updates.
  • Add watches to the community for automation-related content and questions, reading how others have solved challenges
  • Read the weekly release blog from Atlassian to learn about upcoming changes: https://confluence.atlassian.com/cloud/blog
  • Review the open suggestions and defects for automation rules in the public backlog to learn what other people are interested in solving.  This can also help to find out if something you observe is a known defect.  https://jira.atlassian.com/issues/?jql=project%20IN%20(%20%22Automation%20for%20Cloud%22%2C%20%22Automation%20for%20Jira%20Server%22)%20AND%20resolution%20IS%20EMPTY%20ORDER%20BY%20Created%20DESC
  • After you have created a rule, explain in to a teammate to hear their thoughts.  This is a powerful technique as we need to slow down and truly understand a rule to communicate it to another person, and their questions may lead us to other ideas.

 

Suggest an answer

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

Atlassian Community Events