Forums

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

How to use Advanced Branching to create one issue for each unique (distinct) value?

yousefq
Contributor
July 22, 2024

I have multiple issues of type "X" that have a dropdown custom field called "FreelancerName"

and I want to create an issue for each unique FreelancerName value of issuetype = "X" and status = "in progress" 

 

My current implementation:

- Trigger: Scheduled (every 2 weeks)

- filter: issuetype = "X" and status = "in progress"

- Advanced branching: for each smart value:

    - Variable name: {{uniqueFreelancer}}

    - Smart value: {{Issues.customfield_10154.distinct}}

- Action: Create new issue

 

The problem is that I cannot get it to create issues for each unique (distinct) freelancer value :(

 

 

Example: 

I have 30 issues of issuetype "X" and status = "in progress"

only 5 unique FreelancerName values

I expected the automation to create 5 new issues. 

Yet, it created 30 new issues

 

Would really appreciate your help.

and I apologies for my bad explanation of the problem.

1 answer

1 accepted

5 votes
Answer accepted
Trudy Claspill
Community Champion
July 22, 2024

Hello @yousefq 

When you specify a JQL in the Scheduled trigger, then the actions that follow will be executed for each issue returned by that JQL.

I recommend that you take the JQL out of the trigger and instead add a Lookup Issues action to execute that JQL within the rule.

Depending on the frequency of the rule a given issue may be included in the JQL results again by subsequent executions of the rule. That could result in more issues being created than you intend.

Do you need to add some additional constraints so you don't get duplicates, like maybe a criteria to get only issues created later than the last time the rule ran?

And what if the value in the field changes, but you already created the additional issue based on the previous value? Do you want another issue created?

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.
July 22, 2024

Hi @yousefq 

Adding to Trudy's suggestions...

And then change your advanced branch to use the lookup issues as its input, iterating over the distinct values.

  • trigger: scheduled, with no JQL
  • action: lookup issues, with the JQL you originally had in the trigger
  • advanced branch: over the values in {{lookupIssues.customfield_10154.value.distinct}}
    • action: create issue

This assumes your custom field is a single-selection, option field.

And FYI, I note you used the plural {{issues}} smart value.  That one is only supported for Jira Server and Data Center versions of automation.  Please use the Lookup Issues action instead for Jira Cloud.

Kind regards,
Bill

Like # people like this
yousefq
Contributor
July 22, 2024

It Worked!!!  Thanks Trudy and Bill!

 

Much appreciated 

Like # people like this
Trudy Claspill
Community Champion
July 22, 2024

I did leave that detail out, didn't I @Bill Sheboy ? 

You always provide excellent additional details!

Like Bill Sheboy likes this

Suggest an answer

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

Atlassian Community Events