Get Project ID from Quick Create Issue Dialog JavaScript

Brady Shober November 14, 2019

We are using the Scriptrunner plugin and would like to have a Javascript fragment that needs to get the Project ID of the selected project on the quick create issue dialog window. We have gotten the fragment to run on this window but are having trouble getting the project ID. What is the best way to access this?

2 answers

1 accepted

0 votes
Answer accepted
Brady Shober November 18, 2019

I was able to access this using

var projectId = AJS.$("input.project-field")[0].value;
1 vote
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 15, 2019

Examine the elements in the developer panel of your browser with the Quick Create issue dialog open. Search for the project key you've selected.

You should find that there is a hidden form field title projectKeys

I think should be able to fetch it with

var pkey = $('input[title="projectKeys"]').val()

Oh wait, you wrote project id.

That might be harder, but you can try the same steps.

In my case, I could find a project id value here:

var pkey = $('#project').val()

When all else fails and you need an attribute that's not available when you need it, you can create a new "web panel" fragment. This will let you write a bit of groovy and you can output a meta tag like <meta name="mycustomMetaTag" content="somevalue from groovy">.

Then you can set the context and location of when this gets outputted and read it with javascript.

Suggest an answer

Log in or Sign up to answer