Forums

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

Automation avoid duplicates during loop creation

Olga Videc
Community Champion
March 5, 2025 edited

Hello, 

I have an specific case of automation.

Each story/task has a field called System it's a asset filed and what I want to do is create a separate change request in another project for each of those systems.

The tricky part is some story's have a same system (the value is the same) so no need for duplicate issues.  The trick is to catch and compare the issues that are created during this automation the issue is that the create branch in this automation is a separate branch and i cant check them.

Has anyone had similar issue?

BR, Olga 

 

1 answer

1 accepted

0 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.
March 5, 2025

Hi @Olga Videc 

Does your rule do / check anything else with the issues found in the released version?

If not, perhaps consider this approach using a lookup to find the distinct System values:

 

One possible challenge with this approach is asset values can have delays looking up their data, so I recommend testing with practice rule which only writes to the audit log.  For example:

  • trigger: manual
  • action: lookup issues with JQL to gather issues for an example Fix Version value
  • smart values condition: to confirm results were found
    • first value: {{lookupIssues.size}
    • condition: greater than
    • second value: 0
  • log: to write the distinct values for the System field
distinct System values: {{lookupIssues.System.distinct}}

 

Kind regards,
Bill

Olga Videc
Community Champion
March 11, 2025 edited

Hello Bill, 

Thanks for the comprehensive answer—it really got me thinking in the right direction. I totally forgot about the distinct function 😅, but I tested everything else—that’s why I asked.

The distinct list function works in combination with advanced branch.

For anyone who comes across this in the future, here are a few tips:

  • The delay or re-fetch does not work. You also cannot retrieve or compare the issues created in the branch you triggered, as they are created in a separate branch and are not accessible within the same automation.
  • If you use the lookup issues function, this is the value you use in advanced branch:
    {{lookupIssues.Systems.name.distinct}}
    Here, Systems.name represents a field called System (which is an asset field), and name is its attribute.
  • When retrieving data, it will appear as a list, e.g., [OB-123], [OB-456], etc. To clean it up, use:
    {{Variable_name.replace("[","").replace("]","").replace(" ","")}} and then use .split(",")
    This will format the data into a clean list if needed.
  • Variables only work within a branch.

Hope this helps!

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.
March 11, 2025 edited

Thanks for the additional information about your solution.

FYI -- an article from Atlassian recently revealed the flatten function to help with nested lists.  Perhaps try writing this to the audit log in order to merge the lists:

{{lookupIssues.Systems.name.flatten.distinct}}

For the data you show, that would produce this:

OB-123, OB-456

If that works, use it in the Advanced Branch value and remove the bracket handling logic.

 

Like • Olga Videc likes this

Suggest an answer

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

Atlassian Community Events