Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

ScriptRunner - Behavior - How to get Project Category in ScriptRunner Behavior

Ishan Mandhan August 1, 2023

I need to make a field mandatory if the Project category matches certain conditions

How do I fetch Project information inside the  Behavior Script


I am working on Jira Cloud Environment.

1 answer

0 votes
Deepak Jain
Community Champion
August 1, 2023

Hi @Ishan Mandhan ,

Thanks for reaching out here in Atlassian community.

You can try something like this:

Fetch all projects and check with category, if category matched you can mark the Field mandatory: 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.ProjectManager

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def projectManager = ComponentAccessor.getProjectManager()
def projects = projectManager.getProjectObjects()

def filteredProjects = projects.findAll{
if(it.projectCategoryObject) {
if(it.projectCategoryObject.name in ["Common", "Engineering"]) {
it
}
}
}


See if this is helpful !!

Regards,

Deepak

 

Ishan Mandhan August 1, 2023

Hello Deepak

Despite attempting to utilize these Components and Objects, they do not function in the Jira Cloud Environment.
However, I truly appreciate your valuable input and efforts to assist me in finding a solution. Your support is highly appreciated, and I remain open to any further suggestions or alternatives to address this issue effectively.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events