How to get the issue priority with Scriptrunner for Jira Cloud

Alex Kuterman January 26, 2020

How can I read the issue priority with a ScriptRunner?

4 answers

1 vote
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 27, 2020

Hi Alex,

Thank you for your question.

I can confirm in ScriptRunner for Jira Cloud that you can call the Issue API which is documented in the Atlassian documentation page located here with a Get request.

Calling this API will return the JSON for all fields on the issue and one of the fields inside of the JSON will be the Priority field and you will see in the JSON the structure used to store the data for the field in order to determine how to extract its value.

I can confirm that the easiest way to test this is to navigate to the Script Console page inside of ScriptRunner for Jira Cloud and to click on the link named Get Issue Fields in the Examples section below the code box.

This will populate the code box with an example script to call the Issue API and all you will need to is to change the issueKey variable to your Issue Key and run the script in order to return the JSON showing all the fields on the issue. 

I hope this information helps.

Regards,

Kristian

1 vote
Ganesh Babu
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 26, 2020

Hi @Alex Kuterman 

In Jira Cloud, everything you do with Scriptrunner is by JIRA REST API.

So simply follow the REST API:

https://developer.atlassian.com/cloud/jira/platform/rest/v3/?utm_source=%2Fcloud%2Fjira%2Fplatform%2Frest&utm_medium=302

And create a listener in Scriptrunner to perform a REST API to get the issue priority

1 vote
Mario Abud
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.
January 26, 2020

Hi @Alex Kuterman

issue.get("priority").getName() //return the name of priority of the issue.

issue.getPriority().getId() //return the ID of the priority of the issue

Regards

Alex Kuterman January 26, 2020

Hi @Mario Abud,

I am using Jira Cloud.

I cannot use the getName() method

0 votes
Stephen Wright _Elabor8_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 26, 2020

Hi @Alex Kuterman

Not my area of expertise, but I found this answer in a similar question which might be of use :)

Ste

Alex Kuterman January 26, 2020

Hi @Stephen Wright _Elabor8_ ,

The answer you attached is for Jira Server.

It doesn't work on Jira Cloud

Suggest an answer

Log in or Sign up to answer