How to update issue rank when status changes with Jira Automation?

Alejandro Blanco September 28, 2022

Hi. I'm trying to update the rank of issues when they get moved to a new status (column in board). I want to create an automation rule that will rank all new issues in that column to its very bottom.

So far I have been unsuccessful. I've tried to edit the rank custom field with the advance JSON update syntax:

{
"fields": {
"customfield_10019": {
"rankAfterIssueIdOrKey": null,
"rankBeforeIssueIdOrKey": null
}
}
}

And I've also tried using a pivot issue (always at the bottom of the column), putting its ID in the rankAfterIssueIdOrKey property, but that doesn't work either.

How can you edit the issues' rank with Jira automation?

1 answer

1 accepted

0 votes
Answer accepted
Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 28, 2022

Hi @Alejandro Blanco 

this seems similar to a question I answered in the past. Please see my answer in the link below:

https://community.atlassian.com/t5/Jira-Service-Management/Move-cloned-issues-to-top-of-the-backlog/qaq-p/2116786

 

Best
Stefan

Like Stefan Salzl likes this
Alejandro Blanco September 29, 2022

I've managed to pull it off. I'll leave a description of the solution here, in case someone else comes looking for the same behaviour.

I've created an automation rule like this:

  • When: Issue transitioned to <status>
  • Send web request
    • Figure out latest issue in the column
  • Send web request
    • Update rank value for the issue being moved

For the first request I've used the /rest/api/3/search endpoint. That accepts a JQL query, I've used this:

project = <proj_name> AND status = <status_name> ORDER BY Rank DESC

That return the list of issues in the column (status) that we want, with the one at the bottom being first in the list.

Docs: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/#api-rest-api-3-search-get

For the second request I've used the /rest/agile/1.0/issue/rank endpoint. That accepts a JSON file where you send something like this:

{
"rankAfterIssue": "{{webResponse.body.issues.first.key}}",
"rankCustomFieldId": 10019,
"issues": [
"{{issue.key}}"
]
}

Use {{webResponse.body.issues.first.key}} to access the result of the previous request, the last ticket in the column.

You will have to figure out what the rank custom field id is in your project. You can do that by inspecting the Jira website, looking at the column in a JQL search (add the rank column to the results).

Docs: https://developer.atlassian.com/cloud/jira/software/rest/api-group-issue/#api-rest-agile-1-0-issue-rank-put

For both requests I've used basic auth: https://developer.atlassian.com/cloud/jira/platform/basic-auth-for-rest-apis/

I don't think it would be possible to use oauth for requests made from Jira automation.

Like # people like this
Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 29, 2022

Hi @Alejandro Blanco 

Wow.....Awesome effort! Thanks for sharing your solution in such a detailed way so that other community users can benefit from it.

Best
Stefan

Like # people like this
Óscar Giménez February 22, 2023

Hi @Alejandro Blanco !

Thanks for sharing your solution, that's great!.

Edited: I was pointing to ".com" instead ".net".

Alejandro Blanco February 22, 2023

Hi Óscar. Is that you domain? myjira.atlassian.com?

That sounds weird. Are you sure you're sending the request to right endpoint?

Other than that, it looks good, that's basically the same configuration I have working on my project.

Like Óscar Giménez likes this
Carlos April 19, 2023

This is incredible. Thank you @Alejandro Blanco for this incredible automation approach for changing Jira rank. Cannot believe it's 2023 and it's an out of the box feature in Jira. Thanks again. 

Like Alejandro Blanco likes this

Suggest an answer

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

Atlassian Community Events