Forums

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

How to get status value via javascript

Raju KC
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 25, 2013

Below js does not work for me in v5.1

AJS.$("#status").val()

Any help!!!!!

2 answers

1 accepted

1 vote
Answer accepted
Mizan
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 25, 2013

You can get the status of an issue through REST api

/rest/api/2/issue/{issueIdOrKey}

You will get a json output which contains the status value , u can process it to get the status .

EDIT : Try below javascript

<script type="text/javascript">

function getCurrentStatus()
{
var statusname;
     AJS.$.ajax({
        url: "/rest/api/2/issue/XYZ-123",
        type: 'get',
        dataType: 'json',
        async: false,
        success: function(data) {
            statusname = data.fields.status.name;
        } 
     });
     return statusname;
}

alert("Status : " +getCurrentStatus())
</script>

Ryan Aherne
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 2, 2013

What would I need to modify in above code to get it to work with JIRA 4.4.5?

Any help appreciated ;o)

Ryan Aherne
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 2, 2013

For JIRA 4.4.5

function getCurrentStatus(){ var statusname; AJS.$.ajax({ url: "/rest/api/2.0.alpha1/issue/CAR-20", type: 'get', dataType: 'json', async: false, success: function(data) { statusname = data.fields.status.value.name; } }); return statusname; } alert("Status : " +getCurrentStatus())

Ryan Aherne
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 2, 2013

For JIRA 4.4.5

function getCurrentStatus(){
var statusname;
     AJS.$.ajax({
        url: "/rest/api/2.0.alpha1/issue/XVY-123",
        type: 'get',
        dataType: 'json',
        async: false,
        success: function(data) {
            statusname = data.fields.status.value.name;
        } 
     });
     return statusname;
}
 
alert("Status : " +getCurrentStatus())

1 vote
Josh Simnitt
Contributor
July 26, 2018

In JIRA 7, you have the option to use this code to get the current IssueKey. 

JIRA.Issue.getIssueKey(); 


So they can be combined to dynamically get the status of the issue you are viewing:

function getCurrentIssueStatus()
{
var statusname;
var issueKey = JIRA.Issue.getIssueKey();
AJS.$.ajax({
url: "/rest/api/2/issue/" + issueKey,
type: 'get',
dataType: 'json',
async: false,
success: function(data) {
statusname = data.fields.status.name;
}
});
return statusname;
}

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, loom, loom for training, loom for teaching, video training, async learning, online education, screen recording, loom tutorials, loom use cases, atlassian learning, team training tools, instructional video, virtual training tools

🛗 Elevate Your Training and Enablement with Loom

Join us June 26, 11am PT for a webinar with Atlassian Champion Robert Hean & Loom’s Brittany Soinski. Hear tips, stories, and get your burning questions answered. Learn how Loom makes training and enablement easier. Don’t miss it!

Register today
AUG Leaders

Atlassian Community Events