Hello out there,
I want to automatically set the project category in a groovy script. I found out that Project class has a field for category and there is an interface for retrieving the categories. But I cannot find how to get an instance of that interface.
This is what I found so far:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.entity.ProjectCategoryFactory
import com.atlassian.jira.project.Project
import com.atlassian.jira.project.ProjectCategory
import com.atlassian.jira.project.ProjectCategoryStore
import com.atlassian.jira.project.ProjectManager
Long categoryId = ProjectCategoryFactory.NONE_PROJECT_CATEGORY_ID
ProjectManager projectManager = ComponentAccessor.getProjectManager()
Project project = projectManager.getProjectObjByKey("MYKEY")
ProjectCategoryStore categoryStore = // TODO retrieve Project Category Store Instance
ProjectCategory myCategory = categoryStore.getProjectCategore(categoryId)
project.proctCategory = myCategory
A similar question was asked and answered previously in this Community Post.
Below is the sample code suggested:-
import com.atlassian.jira.component.ComponentAccessor
def projectManager = ComponentAccessor.projectManager
def projectList = projectManager.getProjectObjectsFromProjectCategory(10300)
def newCat = projectManager.getProjectCategoryObjectByName('Close')
projectList.each{
projectManager.setProjectCategory(it,newCat )
}
Thank you and Kind regards,
Ram
Thank you, that solved my problem :-)
I have another question: While performing my tests with frequent code changes I experience the annoying problem that ScriptRunner did not compile my recent changes but ran with an older version. How can I force recompilation of the current code?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Where to pass the projects? I need to set Project category for few projects .
Please suggest.
Regards
Likhitha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.