Forums

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

How can I loop thru issues from a JQL Query and update a field with an incremented counter in Jira ?

Cash Coyne
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.
June 11, 2025

I'm in Jira Cloud trying to have a custom rank for my issues that the user enters, like 1, 2, 3,...N.  But when the user wants to have an issue between 1 and 2, they can enter a rank of 1.5, which is fine.

What I want to do is be able to periodically reset the rank with Automation so that they maintain the same order, but are re-ranked with whole numbers 1, 2, 3, ...N

In automation, there are different ways that I can query with my JQL:

Project = MyProc order by MyRank asc

I can use a branch on lookedup issues or branch on JQL so I can update each issue.  But I can't figure out how to have a counter in automation that doesn't get reset with every loop as it processes each issue.  If I could do that, I could just increment the counter by 1 with each loop and each successive each would get a new MyRank whole number.

How can I do this?

2 answers

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

Hi @Cash Coyne 

Automation branches on more than one thing execute in parallel and asynchronously.  There is no guarantee of the processing order and no information is retained after each pass through the loop.  And so, there is no way using created variables to increment a counter with such branches.  At some point in the future, this may change if the option to process such branches serially is added.

 

There are several possible workarounds for this scenario, some outside of automation rules:

  1. Using lookup work items / issues and your ordered JQL expression, create a variable with the lookup keys / index+1 as a list of delimited pairs, then branch on the same JQL and use a match() expression over the stored delimited pairs list to find the index for your work item.
  2. Investigate marketplace apps which have a calculated field mechanism to set your ranking number
  3. Or, don't do this and just rely on the built-in Rank mechanisms and re-evaluate why a separate number is needed.

 

Kind regards,
Bill

2 votes
arielei
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.
June 11, 2025

Hello @Cash Coyne 

Try creating a VAR outside of the loop, set it to 0.

Then inside the loop, increment it.

 

It should work.

Suggest an answer

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

Atlassian Community Events