Forums

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

Development (JIRA): How to get current project object?

wajdhaikal
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 29, 2012

Hi All,

I know that Issue.GetProjectObject() , returns the project the issue relates to, but in create issue screen, the issue context is not null but I can not get the ProjectObject?

Im programming a control behavior and need to know at create stage what is the current project the create is for.

Thanks

4 answers

1 accepted

1 vote
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 29, 2012

You can get the project id from ActionContext like this:

(String[]) ids = ActionContext.getParameters().get("pid");
String pid = ids[0];

And then use the id to get the project object.

wajdhaikal
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.
March 2, 2012

done I have the ID, but how to get the project key ? the object it self?

Mizan
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.
March 2, 2012

ComponentManager().getInstance().getProjectManager().getProjectObj(Long Id); this will return the project.

You will have to cast your pid into long and pass as a parameter to the above method . You can refer the api docs .

1 vote
Mizan
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 29, 2012

Hi ,

Try the below code it might help

import org.ofbiz.core.entity.GenericValue  
import com.atlassian.jira.issue.Issue;

GenericValue project = issue.getProject()

I have used this in one of my postfunction which works before the issue is created .

Sarika Dalal
Community Champion
January 13, 2017

Hii Mizan ,

Thanks it is working for me

0 votes
Apurva Gokani
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!
April 2, 2019
ProjectActionSupport projectSupport = new ProjectActionSupport();
Project currentProject = projectManager.getProjectObj(projectSupport.getSelectedProjectId());
System.out.println("The Name For Current Project: " + currentProject.getName());
0 votes
Kannan S
Contributor
February 3, 2014

The JiraWebActionSupport.java has a method called

getSelectedProjectObject()

So if your java program extends this action, simply call this method like

Project project = getSelectedProjectObject();

which will give you the last accessed project.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events