Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get the name of the project category?

Is there a way to copy the name of the project category the project of the issue belongs to into a special custom field wihtin a post function?

1 answer

1 vote
Tarun Sapra Community Leader Aug 05, 2016

You can use script runner plugin to  fetch the value and then update the custom field

getProjectCategoryForProject(Project project)

Thanks. I tried that, but I get always the same error: 

image2016-8-5 16:34:44.png


Tarun Sapra Community Leader Aug 05, 2016

Have you used script runner / groovy before?

You need to import the classes, the snippet which I shared with you is from the docs and thus you need to create an instance of the class ProjectCategory and then update  the custom field.

Yes I used sript runner and added a groovy scripted field, but I didn't import any classes.


So I guess I first have to figure that out, right?

Tarun Sapra Community Leader Aug 05, 2016

Yes, just import the class, it's easy, look up the api in the link i shared.

Tarun Sapra Community Leader Aug 05, 2016
import com.atlassian.jira.project.ProjectManager

and then create an instance of this class and call the getProjectCategoryForProject(Project project) method and then you can get projectCategory object and get the name of the category

import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.component.ComponentAccessor
//Test para Console
def issueKey = "IESD-14862"
def issueManager = ComponentAccessor.getIssueManager()
def issue = issueManager.getIssueObject(issueKey)
//def issue = issue as Issue"issue: "+ issue)

def projectManager = ComponentAccessor.getProjectManager()
def project = projectManager.getProjectCategoryForProject(issue.getProjectObject())


Like Danila Bystrov likes this

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Apps & Integrations

Send an Email or Publish to Confluence - What should you do with your release notes?

Background When you hear the words ‘Release notes’, almost always you think of an unsolicited email from a software vendor. But I am here to tell you that from our data, sending release notes via E...

124 views 1 2
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you