Is there a way to use JavaScript (in the comment area of a custom field) to read the current issue id?
Regards Uwe
Community moderators have prevented the ability to post new answers.
AJS.$("meta[name='ajs-issue-key']").attr("content")
in recent versions of jira. Think there is also a helper js function that will give you it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
is not working in JIRA 7.0.10
Use instead:
JIRA.Issue.getIssueId()
JIRA.Issue.getIssueKey()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I usually use:
JIRA.Issue.getIssueId() JIRA.Issue.getIssueKey()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This seems to be the most reliable option now. If you are on a workflow transition screen, then JIRA.Issue will work when using transition from issue view, search results view, and JIRA Agile view. The metadata options do not work from the JIRA Agile view at least in 6.1.7.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is there any documentation javascript JIRA object ? Could you point me some links?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I couldn't find such documentation. I don't think this is official API, it is probably just for Atlassian. Since it is javascript though we can use it. I use the development tools in Chrome, though other browsers have these too. Any that provide auto-complete will let you see the different objects and methods available.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This one kind of "works". When editing an issue, it correctly returns the issue id, but when clicking "create" in the issue navigator. it STILL returns the id of the selected issue (instead of null because you're creating a NEW issue which has no id yet).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We have a bit of API niceness to get at meta data. It is preferred to use:
AJS.Meta.get("issue-key")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
JIRA.Issue.getIssueId()
JIRA.Issue.getIssueKey()
DOESN'T work for NEXT GEN templates based projects
I wrote bug report about it ~ 4-5 months but nothing changed
Any hacks/ideas how to resolve issueId using JS?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
One thing that seems to work correctly for both creation and edit mode is to look in the "jiraform" form and search for the hidden "id" input. In creation dialogs, this element is not present. (JIRA 6.4)
The following will return the id as a string, or undefined for creation mode: AJS.$('form[name=jiraform] input[name=id]').prop('value')
.
Of course, future versions with changed HTML might easily break this, so a much preferred solution would be to fix the behavior of JIRA.Issue.getIssueId()
, as that one's actually readable.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In JIRA 7.0.10 the behavior is fixed:
JIRA.Issue.getIssueId()
JIRA.Issue.getIssueKey()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.