It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Get issueID in JavaScript in Project Screen (viewing issue)

Hello to all,


I am having a problem where I have no idea where to find a solution or what to search for, so I'm asking this Question. A little context ahead:

I'm writing a plugin that shows some additional information on the ViewIssueScreen. Placing it right on the standard viewing screen for issues (like eg. structure plugin etc.). I use some velocity and JavaScript to postprocess and display some informations. To do that I'm using my own REST Resource which requires the issueID to work with. I could also use the issueKey, but at this point this doesn't change anything or help.

So I found this to get to the issueID (or key) with

 var issueID = JIRA.Issue.getIssueId();
 var issueKey = AJS.$("meta[name='ajs-issue-key']").attr("content");

This all works fine up until this:


When I go to the project of the issue, where all issues that belong to it are listed on the left, and the issue clicked is displayed in a screen right side next to it, it can't retrieve the id or key anymore. It just gives back null and undefined.

How can I get the issueID or issueKey within the ViewIssueScreen where it doesn't matter if its a subpage or not?

1 answer

1 accepted

2 votes
Answer accepted

Hello, Christian. Thanks for reaching out to the Atlassian Community!

I've tried getting the issue key in the issue navigator with the AJS.$("#key-val").text() command but the same behavior happened, it returned null. After some search I was able to find out that it might be because the callback is pointing to the first HTML that rendered which doesn't have the class with the "key-val" id, the problem being the inline editing.

This other question from the Developer Community is describing something similar: Parts of javascript not working in issue navigator

One of the answers suggested is listening to a Jira JS event and then executing the code inside the listener function. I've created the following code and it seems to be working for the purpose of retrieving the issue key.

JIRA.bind(JIRA.Events.ISSUE_REFRESHED, function() {
var key = AJS.$("#key-val").text();
console.log("Issue Key: " + key);

There's further information on extending the inline editing in Jira is this page: Extending inline edit for JIRA plugins

Kind regards,
Maurício Karas

This is likely the most valuable answer I have ever received, thank you very much, also for the quick response. So now I'm calling my setup function from this event bind and pass the issue-key and it works smoothly.

I didn't know about all this inline stuff, this will help a lot in the future too.

So maybe you have time for a little more follow-up questions out of curiosity:

Why is it that always people recommend using the issue-key and never issue-id? I mean if they are both unique, why even bother to have two?

How would I get the ID then? AJS.$('#id-val")?


Best regards,


Glad to hear it worked on your end and that I was able to help.

I don't know exactly why is that the issue key is more used, you're right, they're both unique. I think it's because the issue key is more meaningful than the id, the issue key shows up in the Jira GUI so you can easily find what issue you are referring to.

Yeah, to get the id, the "id-val" doesn't seem to work. If you inspect the issue key next to the project's name you can see rel="<id>", which is the id you want. Another way that I've found, which I can see people using, is the following:


This worked for me and I think is more readable than getting fields and HTML elements.

Kind regards,
Maurício Karas


 This is of course the solution I tried at first (as stated), but this is exactly, where the inline doesn't work anymore. Imho it should still work then.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

We want to hear from you! How do you use Slack and Atlassian together?

Hi Everyone! My name is Mina and I am on Atlassian’s Ecosystems Marketing team. Our team is focused on our technology partnerships and marketplace apps. One of Atlassian’s partners is Slack, who ...

85 views 1 5
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you