View issues that have been moved from one project to another

kbestla
Contributor
May 7, 2018

Hi there

I would like to get an overview of how many issues have been moved from one Project to another Projects, fx. how many issues were actually created within Tech Support / Service desk project but moved to Web Development project or Sales Project etc.

 

Is this possible somehow?

 

Best regards

Kristín

 

 

8 answers

2 accepted

5 votes
Answer accepted
Thompson Cherian
Contributor
May 7, 2018

By default this is not possible to do via JQL Search.  ( Request dear Community members to correct me if I am wrong). Maybe via advanced search using Scriptrunner or directly running the correct query in the database you might be able to achieve the same.

But in the future if you require to search issues moved from one project to another. Create a Custom Field named " Previous Project " and use a workflow transition add-ons (JWME, ScriptRunner etc) to copy the value of Project Name/Key into the this Custom Field via a post function during issue creation.

Now even if the issue is moved, the value of the field remains the same and you can use JQL to search and find moved issues from the previous project name.

kbestla
Contributor
May 8, 2018

Thank you - Solved with Script Runner :)

Vijay Sv
Contributor
September 20, 2018

@kbestla., I have a similar requirement, can you please share the script which worked for you to solve this.

Thanks in advance!!

Kristín Bestla Þórsdóttir
Contributor
September 21, 2018

Hi @Vijay Sv - I used the script from Henning Tietgens from this page:

https://community.atlassian.com/t5/Jira-questions/How-to-find-issues-that-were-moved-from-one-project-to-another/qaq-p/49115

 

Here is the script:

 

package eventim.scripts

import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.web.bean.PagerFilter

jqlQuery = 'project = BBB'
fromProject = 'AAA'
result = ''

def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()

getFilterResult(jqlQuery,log).each{ Issue issue ->
oldKeys = changeHistoryManager.getPreviousIssueKeys(issue.id)
oldKeys.findAll{it==~/$fromProject.*/}.each{
// result += "$it -> ${issue.key}\n"
result += "$it,${issue.key}<br>"
}
}

return result

List<Issue> getFilterResult(String jqlSearch, log) {
def searchService = ComponentAccessor.getComponent(SearchService.class);
def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
List<Issue> issues = null

def parseResult = searchService.parseQuery(user, jqlSearch);
if (parseResult.isValid()) {
def searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
issues = searchResult.issues
} else {
log.error("Invalid JQL: " + jqlSearch);
}
return issues
}

Like # people like this
Vijay Sv
Contributor
September 21, 2018

Thanks @kbestla:)

4 votes
Answer accepted
Manon Soubies-Camy
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 7, 2018

Hello Kristin,

You can't do this out of the box since the WAS and CHANGED operators can be used with the Assignee, Fix Version, Priority, Reporter, Resolution and Status fields only.

If you're on Server, you can do this with JQL Tricks though:

issue in movedIssues("project","Project A","Project B") - Returns all moved issues from "Project A" to "Project B"

(see documentation)

I guess you could also do this with ScriptRunner.

Hope this helps,

- Manon

kbestla
Contributor
May 8, 2018

Thank you. I tried out JQL Tricks, looks like they have an error because this  query does not work "issue in movedIssues("project", "project A", "project B")". I've written to them but they did not answer.

 

So, I used script runner to solve this :)

Matt Doar
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 14, 2020

How did you use ScriptRunner to do this? Oh I see a reply below

Like Henrique Prado likes this
9 votes
Giulyanna Loureiro
Contributor
January 29, 2021

Just commenting on this hoping it becomes something that could be done via JQL one day...

4 votes
Abhay Patil
Contributor
April 8, 2022

If the initial and destination projects use different sets of status' then one can figure what moved from project A to Project B.

E.g. if project A always uses a status = review before the issue is moved to project B, where "review" status is not used, then the following query will find all the issues in project B that have project A pedigree.

project = B and status was in (review)

This will not find issues that were created in Project B (and not moved from Project A).

Joao Arruda
Contributor
September 18, 2024

I wasn't aware of the "WAS IN" operator in JQL, that's extremely clever, thanks!

Like Abhay Patil likes this
Fiona Brown
Contributor
November 13, 2024

Thanks for this answer Abhay - this solved it for me!

Like Abhay Patil likes this
2 votes
Gezim Shehu [Communardo]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 7, 2018

I think it might be doable.

Upon moving an issue, issue key is changed and this information is saved in issue change history.

 

Now this is certainly searchable by querying the database. I think it can also be searched via Script.

issue history.JPG

kbestla
Contributor
May 8, 2018
Gezim Shehu [Communardo]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 8, 2018

Nice :)

0 votes
Rachit Singhal
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 14, 2023

Hi All,

 

I have figured out a way by which plugin won't be required and it can be performed using built-in functionality of automation (if using cloud).

 

Here are the steps:

 

  • Create one custom field of type text, let's say previousProject.
  • Create one automation on multiple issue events upon issue created, issue updated, issue transitioned etc. (If you are creating this automation in advanced then issue created only) and then apply the action on Edit issue fields for the above custom field to set the value of project name "{{project.name}}". This automation will capture the value of project. Make sure to apply condition for this field to be empty if choosing first option to avoid multiple run of the automation for the same purpose.
  • Add one more automation on "Issue moved" condition, select any project or particular project as per your requirement and then select action of Send email to your mail id having some required information of that issue but make sure to get the value of the custom field that we have created.
  • You can avoid the second automation if you are okay to export the issues whenever you need this value. 

 

For the above automation, you will be required to have the knowledge of smart values. You can refer to the below document for it. 

https://support.atlassian.com/cloud-automation/docs/smart-values-in-jira-automation/

 

Please let me know if anyone has any question. 

 

Thanks,

Rachit Singhal

0 votes
Dao Starita December 16, 2021

We are running JIRA Server version. The below JLQ works for me: project = "Project A" AND issue in movedIssues("Project B")

  • "Project A" is the destination project
  • "Project B" is the original project where the issues were filed to

No need for installing Script Runner.

samerharb
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 28, 2022

The functionality "issue in movedIssues" is not native in Jira

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events