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

This widget could not be displayed.
Tarun Sapra Community Champion Aug 05, 2016

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

ProjectCategory
getProjectCategoryForProject(Project project)

https://developer.atlassian.com/static/javadoc/jira/latest/reference/com/atlassian/jira/project/ProjectManager.html

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

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

 

Tarun Sapra Community Champion 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 Champion Aug 05, 2016

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

Tarun Sapra Community Champion 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

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted yesterday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

68 views 0 1
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you