Forums

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

Automation: Give ascending numbers in custom field based on rank

Oriyah Barzilay
Contributor
August 16, 2023

I am searching for issues using a JQL (that has order by rank), then based on those results I want to fill in ascending numbers in a custom number field. Can I do that simply with a smart value or do I need to constantly refetch the data?

3 answers

1 vote
Oriyah Barzilay
Contributor
November 15, 2023

Hey everyone we ended up writing our own script for this that was the only solution

0 votes
Stefan Draber
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.
October 11, 2023

Hi @Oriyah Barzilay and @Bill Sheboy

as we're trying _exactly_ the same, I'd like to share some thoughts on it.

As I understand the checkbox in the trigger-configuration, the following actions will be executed for each result of the JQL-query. Since the query already puts the issues in the wanted order (sorted by rank), this part of the problem should be solved.

The tricky part is: in the triggered action-configuration, how can I update the custom field in each ticket with an iterating number? Like, first issue in my set of JQL-query-results = 1, second issue = 2, third issue = 3 and so on?

If we don't find a solution within Jira Automation, we'll have to solve it via REST API, python script (already built and tested) and scheduler, but that obviously seems a bit over the top.

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.
October 11, 2023

Hi @Stefan Draber 

I believe what you describe about the order-processing of issues for the trigger is not possible.  Automation rules which process multiple things (from triggers or branches) do so in parallel and asynchronously.  There is no way to count, in order, using those methods.

There is complicated work-around using the Lookup Issues action and created variables (if you are using a version of automation rules which support those actions...

  • Use a Lookup Issues action, with JQL to return the issues in the desired order.  The lookup will preserve the order to allow for use later.
  • Iterate over that result, and save the value in created variable (e.g., named varOrderList, using this:
    • {{#lookupIssues}}{{key}};{{#=}}{{index}}+1{{/}}{{^last}},{{/}}{{/}}
    • That will produce a comma-separated values list of keys and their order, from 1 to N
  • advanced branch over the same JQL used for the lookup issues action
    • create a regular expression to search for the current issue in varOrderList with: {{issue.key}};(.*)
    • search for the order value with {{varOrderList.split(",").match(varSearch)}}
    • use that value to update your custom field with the order

This is a slower rule, as it iterates over all issues in the JQL.  And, it is limited to 100 issues, as that is the current limit for such branches.

Kind regards,
Bill

Like Stefan Draber likes this
Stefan Draber
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.
October 12, 2023

Hi @Bill Sheboy 

thanks a lot, that sounds as if it could do the job, if there wasn't the limit to 100 issues :\

Do you have any further idea, how we could navigate around this limit?

Best regards,

Stefan

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.
October 12, 2023

The other ways I can think to solve this are...

  • Export the issues, add the counter, and re-import the field for updates
  • Investigate marketplace apps which have scripted/counter fields
  • Build your own function outside of Jira to update the issues, and call that from a rule with Send Web Request
0 votes
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.
August 19, 2023

Hi @Oriyah Barzilay 

Would you please post images of your complete automation rule and the audit log details showing the rule execution?  Those will provide context for the community to offer suggestions.  Thanks!

Until we see those...

Are you trying to update each issue in the results of that JQL, or something else?  There might be a way to do this using {{index}} for an iterator, but without seeing your rule that is difficult to know.

Kind regards,
Bill

Oriyah Barzilay
Contributor
August 20, 2023

Hey Bill, 

 

I want to have a scheduled automation that runs on a JQL.

Based on the JQL results I want it to number the issues in the custom field. (1,2,3,4.... based on the rank)

I know I'm missing something in the middleScreenshot 2023-08-20 125930.jpg

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.
August 21, 2023

Thanks for that information. 

What you are describing is not possible using the Rank field (also known as LexoRank) as that is a non-numeric string of characters, which allows updates to ordering (including inserting issues in the middle of a list) without changing the Rank of surrounding issues.

I have seen other community posts doing this when creating the issues in a rule, but I do not believe it is possible to update existing issues with an incremental counter due to the way branches on more-than-one-issue process: in parallel and asynchronously.

If you need this infrequently, you could try the update using an importhttps://support.atlassian.com/jira-cloud-administration/docs/import-data-from-a-csv-file/

  • select your issues with a query, and export them
  • update your custom field using spreadsheet functions to your increasing counter
  • follow the instructions in the linked documentation above to update existing issues

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