Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Limiting component choice by issue type

Aaron Matthys January 24, 2018

I have a JIRA project with 15 components and 4 issue types. Would like to limit the component choices based on issue type using ScriptRunner Behaviors. Can anyone help me with a shell script to get me started?

JIRA 7.6.1

Scriptrunner: 5.2.2

 

 

 

 

2 answers

Suggest an answer

Log in or Sign up to answer
2 votes
Michel Tremblay [Adaptavist] January 31, 2018

Hi, Aaron, something like this should help you start

import com.atlassian.jira.config.IssueTypeManager
import com.atlassian.jira.component.ComponentAccessor

Map validComponentNameByType = ["Task":
["component1","component2"],
"Story":
["component2","component3"]
]

def project = issueContext.projectObject
def issueType = issueContext.issueType.name
def component = getFieldById("components")

if(issueType && validComponentNameByType[issueType]){
def validComponent = project.getComponents().findAll{it.name in validComponentNameByType[issueType]}
component.setFieldOptions(validComponent)
}
0 votes
Maria Kavoosi May 27, 2022

@Michel Tremblay [Adaptavist] 

Hi Michel,

Thanks for your great answer.

I need to restrict component/s based on request type on customer portal.

Could you please help me to solve it?

TAGS
AUG Leaders

Atlassian Community Events