Child pages
  • How to get Issue ID in Jira?

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
if (issue_key = new URL(window.location.href).searchParams.get("selectedIssue") || (/^\[([^\]]+)\]/g.exec(document.title) || [])[1])
{
	fetch(window.location.origin+'/rest/api/3/issue/'+issue_key)
	.then(res =>{
		if(res.ok)
		 	return res.json()
		else
			throw new Error('Something went wrong')
	})
	.then(data => console.log("Issue ID for "+issue_key+": "+data.id))
	.catch(err => console.log("Error occurred while fetching issue ID: ",err))
}
else {
	console.log(issue_key, "Please run it on Jira Issue view page to get issue ID.")
}

Bookmarklet

You can also add a bookmarklet in your browser's bookmarks bar for quick access.

...

Code Block
languagejs
javascript:(function()%7Bif%20(issue_key%20%3D%20new%20URL(window.location.href).searchParams.get(%22selectedIssue%22)%20%7C%7C%20(%2F%5E%5C%5B(%5B%5E%5C%5D%5D%2B)%5C%5D%2Fg.exec(document.title)%20%7C%7C%20%5B%5D)%5B1%5D)%7Bfetch%0A%7B%0A%09fetch(window.location.origin%2B'%2Frest%2Fapi%2F3%2Fissue%2F'%2Bissue_key)%0A%09.then(res%20%3D%3E%20res(res%3D%3E%7B%0A%09%09if(res.ok)%0A%09%09%20%09return%20res.json()%0A%09%09else%0A%09%09%09throw%20new%20Error('Something%20went%20wrong')%0A%09%7D)%0A%09.then(data%20%3D%3E%20alert(%22Issue%20ID%20for%20%22%2Bissue_key%2B%22%3A%20%22%2Bdata.id))%7Delse%7Balert%0A%09.catch(err%20%3D%3E%20alert(%22Error%20occurred%20while%20fetching%20issue%20ID%3A%20%22%2Cerr))%0A%7D%0Aelse%20%7B%0A%09alert(%22Please%20run%20it%20on%20Jira%20Issue%20view%20page%20to%20get%20issue%20ID.%22)%7D%7D%0A%7D%7D)()%3B

To use it - navigate to any issue in Jira and click the bookmark you have just added – an alert will show with this Issue's ID.

...