Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

how to capture the actual project name when an issue is moved to a new project with issueMoved event?

srinivasp
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.
February 21, 2012

Hi, I am trying to capture the actual project name with issueMoved event when an issue is moved to new project. In the event method i called the getProjectObject() method to verify the project but it is not giving the actual project object but giving the modified project object. what is the best way to get the details about that the actual project.

thanks in advance!

2 answers

1 accepted

0 votes
Answer accepted
Jobin Kuruvilla [Adaptavist]
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.
February 21, 2012

Use ChangeHistoryManager to get the previous issue keys.

http://docs.atlassian.com/jira/latest/com/atlassian/jira/issue/changehistory/ChangeHistoryManager.html#getPreviousIssueKeys(java.lang.String)

Once you get the previous issue key, you can work out the project key from it and retrieve the old project!

Jobin Kuruvilla [Adaptavist]
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.
February 21, 2012

Another option is to check the change history. The old project will be there in the change items.

Jobin Kuruvilla [Adaptavist]
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.
February 21, 2012

Null value indicates that the issue hasn't been moved yet. For an issue that is moved, you should see the previous issue key.

srinivasp
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.
February 21, 2012

Hi Jobin,

I am getting null values if i try to work out with the previous issue keys. Even change history is also not giving any information. Kindly advise.

-Srinivas

Jobin Kuruvilla [Adaptavist]
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.
February 21, 2012

Well, you are trying to get a deleted issue using the previous key. Retrieve the project key from the previous key (anything before the -) and use the project key to get the project.

srinivasp
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.
February 21, 2012
I mean i got the previous issue keys and if i try to get the project name with that keys, i am getting null values.
Collection<String> keys = changeHistoryManager.getPreviousIssueKeys(issue.getKey());
			for(String key : keys){
				MutableIssue  mu = componentManager.getIssueManager().getIssueObject(key);
				try {
					System.out.println(key+" :: "+mu.getProjectObject().getName());
				} catch (Exception e) {
					System.out.println(e.toString());
				}
			}
srinivasp
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.
February 21, 2012

Did not find a method which takes issue key as parameter that returns a project key and so i tried to fetch a project key in the above way. Could you please let me know the class which is to be used here?

Jobin Kuruvilla [Adaptavist]
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.
February 21, 2012

hmm..There is no method that JIRA gives. Try this:

String pKey = key.substring(0, key.indexOf("-"))

srinivasp
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.
February 22, 2012

Hi Jobin,

I am trying to fetch the the actual values of affects version/s field.

I am using the method changeHistoryManager.getChangeItemsForField(mu,"version"); but it is giving me null.

Could you please let me know the name to be user to fetch the affects version/s values?

or Please suggest if there is other alternative way to fetch the actual values of the affects version/s field.

-Srinivas

Jobin Kuruvilla [Adaptavist]
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.
February 22, 2012

Are you using mu where mu is th old issue Object? use the new issue object.

srinivasp
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.
February 22, 2012

Its the new issue object only. So i doubted whether the name("version") i used is correct or not for fetching the affects version/s field information.

srinivasp
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.
February 22, 2012

Hi Jobin,

I am getting the following exception when i try to persist the actual project details to a custom field

java.lang.ClassCastException: class com.atlassian.jira.issue.customfields.impl.ProjectCFType passed an invalid value of type: class com.atlassian.jira.project.ProjectImpl

Please advise on how to capture the actual project name and version to some custom fields.

Thanks in advance, Srinivas

Jobin Kuruvilla [Adaptavist]
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.
February 22, 2012

Srini, Please start a new thread for new discussions.

For Project custom field, you should probably pass the project id and not the Project class.

0 votes
srinivasp
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.
February 21, 2012

any ideas please?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events