Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Automation - How to change issue Rank to the highest

Abir Brahem April 24, 2024

Hello,

 

I am using the automation module to change the Rank of some type of issues: 

Looks like I need to use the "Send web request"

Can you help me plz,

Thanks,

Abir

1 answer

1 accepted

1 vote
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.
April 24, 2024

Hi @Abir Brahem 

What problem are you trying to solve by doing this?  That is, why do this?  Knowing that may help the community suggest additional ideas.

Until we know that...

It is possible to call a REST API function to set the rank of one (or more) issues relative to another issue.  And so the rule would need the key for the issue above / below which to re-rank the target issue.

This how-to article describes how to call a REST API function from a rule using the Send Web Request action: https://community.atlassian.com/t5/Jira-Software-articles/Automation-for-Jira-Send-web-request-using-Jira-REST-API/ba-p/1443828

I recommend contacting your Jira Site Admin before writing this rule as they may provide some additional support.

Kind regards,
Bill

Abir Brahem April 26, 2024

Hello Bill,

Thank you for the link, now I am able to request the JIRA Cloud API.

I would like to change the rank of some type issues to the top.

I found this end point in the documentation:

The Jira Software Cloud REST API (atlassian.com)

I tested with PostMan and I it is possible to change the rank:

rest/agile/1.0/issue/rank

request body:

{
    "issues": [
        "GEN-XXX1"                           => id of the issue to rank, in my case I could use the smart value {{issue.key}}
    ],
   "rankBeforeIssue": "GEN-XXX2"  => the id of highest issue, don't know to get it ???
}
Any help plz?
Thanks,
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.
April 26, 2024

Have you discussed this scenario with your Jira admin yet?  I recommend doing that before you proceed further, as you have not explained the problem you are trying to solve and the conversation with your admin may help.

For example, you do not describe why or when this change of rank is needed, and those impact the rule trigger and issue context for making changes.

 

Regarding the rule specifics, as you have already successfully called the REST API function with PostMan and you have the how-to article for calling the function from a rule, you can use that request body as a template in your Send Web Request action.

Abir Brahem April 26, 2024

Hello,

I am a JIRA admin, unfortunately there no expert more then me in the company.

The trigger is when issue created and if issueType is Bug (I can't add screenshot, I don't now why..)

 

I can't use the send Web Request because I need the highest issue key as I descibe in my last message.

Is that clear?

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.
April 26, 2024

Let's assume this is for one project and you only care about issues in the backlog.  To find the issue which is currently the highest-ranked one, JQL may be used:

project = yourProjectName AND status = Backlog ORDER BY Rank ASC

The first one in the list is the highest-ranked issue.

Thus a rule could use the Lookup Issues action with that JQL to gather the first 100 issues found, and the first in the list would be the key needed for the request:

{{lookupIssues.first.key}}

 

Like Abir Brahem likes this
Brendan Betheldo April 28, 2024

Hi @Bill Sheboy and @Abir Brahem I'm trying to achieve something similar. Reason being is that when issues are created by any one of the 20 members in the team they can be lost in the backlog. 

So I want a rule that that runs once a week to find any issues marked as Security and or Compliance (custom field) and move them to the top of the backlog so that when we do sprint planning those items are always first. 

Does that help with the Why?

Abir Brahem April 29, 2024

@Bill Sheboy 

 Hi Bill, Thank so much, I succesfully update the Rank finally !

@Brendan Betheldo you request is a little bit more complicated: you can Inspired by my rule (see below). First of all, to change the trigger to Scheduled and you need to change the web request body to:

{
"issues": {{lookupIssues.key.asJsonStringArray}} ,  
     "rankBeforeIssue": "{{lookupIssues.first.key}}"
}

You need juste to check if the the smart value returns an array of the liste of all the issues to Rank, I am not sure about the right syntax, @Bill Sheboy what do you think? 

This is my rule:

image.png

Have a nice day,

Abir

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.
April 29, 2024

For the field rankBeforeIssue, only one issue key is expected.  And so using the first one from the lookup helps ensure that.

Also...the criteria for your linked issues condition and the lookup issues are different.  Thus it is possible the lookup issues could return zero or more issues.  (It could return zero due to the possibility of timing issues for the Transition Issue step immediately before the lookup, and so not even the trigger issue is found.)

I recommend two changes:

1) Add criteria to the lookup issues action to exclude the trigger issue with:

AND key != {{triggerIssue.key}}

2) Adding a smart value condition after the lookup to ensure at least 1 issue is found:

  • first value: {{lookupIssues.size|0}}
  • condition: greater than
  • second value: 0

These changes will prevent any attempt so re-rank an issue ahead of itself.

Like Abir Brahem likes this
Brendan Betheldo April 29, 2024

Thank you @Abir Brahem and @Bill Sheboy

Is the authorization in my header just email and API key?

Eg firstname.lastname@email.com.au:xxxxxxxxxxxxAPI_KEYxxxxxxxxxxxxxxx

I've added that in authorization header but I get a 401 and have used the same API key before without issue.

Abir Brahem April 30, 2024

Hello @Brendan Betheldo 

The autonfication Value filed is:

Basic HzxuhHbhzhdjasYTgdjGfrGHzxuhHbhzhdjasYTgdjGfrG 

The key after Basic is YOUEMAIL:API_TOKEN coded id base 64

You can use this online tool to encoded them in base 64 

https://www.base64encode.org/  

Best Regards,

Brendan Betheldo May 5, 2024

Thanks @Abir Brahem and @Bill Sheboy I got the automation working! 

Quinn Wood
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 27, 2024

What was the final version of this PUT body? I have tried both what is included in the above post and screenshot, and I get errors with both.

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.
September 27, 2024

Hi @Quinn Wood -- Welcome to the Atlassian Community!

Context is important for automation rule questions.

Please post an image of your complete rule, an image of the Send Web Request action, and an image of the audit log details showing your rule execution.

And, where are you observing errors: when creating the rule, when running the rule, something else?

Kind regards,
Bill

Quinn Wood
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 27, 2024

I was able to get this working. Thank you.

I didn't have a valid lookup, so the web request was missing the information.

Like Bill Sheboy likes this

Suggest an answer

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

Atlassian Community Events