Get project name in server side script in behaviour plugin

S. Ravi Venkatramana August 25, 2014

Hi,

I could able to fetch project id by using getFieldById("pid")

What should I use to fetch project name?

Thank you

2 answers

1 accepted

1 vote
Answer accepted
Bhushan Nagaraj
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 25, 2014

Try this

import com.atlassian.jira.component.ComponentAccessor

Project project = ComponentAccessor.getProjectManager().getProjectObj(Long.parseLong(getFieldById("pid")))

S. Ravi Venkatramana August 25, 2014

Hi Bhushan,

Thank you for quick reply.

Your suggested method worked perfectly.

Only thing is, instead of getFieldById("pid"), I had to use projectID.getFormValue().

Here is the snippet from my code.

FormField projectID=getFieldById("pid")

Project project = ComponentAccessor.getProjectManager().getProjectObj(Long.parseLong(projectID.getFormValue()))

0 votes
JamieA
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 26, 2014

Bhushan's solution is fine, but I prefer:

getIssueContext().getProjectObject()

getIssueContext() returns a com.atlassian.jira.issue.context.IssueContext which has other useful stuff.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events