We move issues between projects. Is there a query to find all the keys an issue might have had in its lifetime?

Sean deBardelaben August 18, 2013

Is it possible to find all the issuekeys an issue might have had in its lifetime?

3 answers

4 votes
Cyril Egan
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.
August 19, 2013

Install the Script Runner Plugin.

Create a scripted custom field e.g. "Previous Jira Key/s"

Add the following script to the field:

import com.atlassian.jira.ComponentManager
 
def componentManager = ComponentManager.getInstance()
def changeHistoryManager = componentManager.getChangeHistoryManager()
x = changeHistoryManager.getPreviousIssueKeys(issue.id)
if (x.join(' ') == "") {
   return null
}

return x.join(' ')

Make sure the settings for the field are:

Template: Free Text Field (unlimited text)
Configured searcher: Free Text Searcher

Add the field to the view screen for the issue if you want it to appear when you view the issue.

Add it to the Issue Navigator to have it display in search results.


Rathna July 19, 2017

Hi Cyril,

Which version of JIRA does this code work?

Regards,

Rathna

0 votes
Matheus Fernandes
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 18, 2013

Sean,

It is possible to do that through the database running the following query:

SELECT 	ci.oldstring AS "Old Key", ci.newstring AS "New Key", cg.author, cg.created FROM changeitem ci 
	JOIN changegroup cg ON ci.groupid = cg.id 
	JOIN jiraissue ji ON cg.issueid = ji.id
	WHERE ci.field = 'Key' AND ji.pkey = '<issue-key>';

Just replace '<issue-key>' with the current Key of the issue.

I hope this helps! :)

0 votes
RambanamP
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.
August 18, 2013

movedIssues() in JQL Tricks Plugin function will do what you are expecting, check this

https://marketplace.atlassian.com/plugins/com.j-tricks.jql-plugin

Suggest an answer

Log in or Sign up to answer