Can you automatically update the Project Category using a workflow

Ash April 12, 2012

The scenario: We categorise our projects based on a groupings, approval status and whether the project is closed.

e.g. High, Medium, Low, Approved, New ideas... Closed Projects.

This helps us view the Portfolio of projects we have, see what's coming and new idea's (projects) being discussed and what's been closed.

Is there a way to automatically change the project category from say "High" to "closed" using the workflow steps within an issue.

E.g. if the parent issue of the project is closed, then the project category is changed to "Closed Projects"

Thanks

3 answers

3 votes
Dieter
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.
April 12, 2012
Surely this can be done using a groovy post function in the close transition. The necessary api is http://docs.atlassian.com/jira/latest/com/atlassian/jira/project/ProjectManager.html#setProjectCategory(com.atlassian.jira.project.Project,%20com.atlassian.jira.project.ProjectCategory) Of course you would also still need a criteria that tells if the issue is the "parent" issue of your project. The term parent issue in Jira is usually only used in conjunction with sub tasks. in your case it seems to be a tagged issue which represents the state of the project itself
Ash April 12, 2012

Thanks Dieter - I'm not a coder so will have to pass to one of my more intelligent colleagues to try your solution. Cheers

Dieter
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.
April 12, 2012
This should set the project category to "Closed Projects"
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.project.Project
import com.atlassian.jira.project.ProjectCategory
import com.atlassian.jira.project.ProjectManager


Project project = issue.getProjectObject()

ProjectManager projectManager = ComponentAccessor.getProjectManager()
ProjectCategory projectCategory = ComponentAccessor.getProjectManager().getProjectCategoryObjectByName("Closed Projects")
projectManager.setProjectCategory(project, projectCategory)

Ash April 23, 2012

Hi Dieter - I just wanted to say thanks for your help with the above. I've passed this onto one of our developers and it's in their queue (still). Appreciate you taking the time to put the code together.

Dieter
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.
April 23, 2012
Glad to help :) Please consider to accept this answer when the code can be put into production successfully
0 votes
Ash April 12, 2012

Ideally we'd only do this at the last transistion. We have a Parent issue type called Project Management which covers all activities that the PM performs over the life of the project. When that issue type is closed in the last transistion we wanted to update the project category to closed as part of the post function

0 votes
Renjith Pillai
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.
April 12, 2012

But won't it be an overkill to determine the project category during every workflow transistion? And just for my understanding, what do you mean by 'parent issue of a project'?

Suggest an answer

Log in or Sign up to answer