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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

How map componenets to Request Type using ScriptRunner?


How map components to a Request Type for a Service Desk project? We have many components for our Service Desk some are not valid for some Request Type. For example, technical support-related components are not valid for Sales. If customers select "Sales" Request Type it should only display "Purchase" and "Return". If Technical Support then it should display other components. I found a script it works fine with issue types but I don't know how to make it work with Request Type. I don't want to hide components from the backend, just from the customer portal.

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

Map validComponentNameByType = ["Task":
] //Change Task issue type to "Sales" Request Type

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

if(issueType && validComponentNameByType[issueType]){
def validComponent = project.getComponents().findAll{ in validComponentNameByType[issueType]}

I'll be thankful if someone helps me update the script for Request Type.

Thank you

1 answer

1 accepted

0 votes
Answer accepted

Behaviours comes with a "getRequestTypeName()" method that you can call.

Armed with that, you can convert that script to something quite simple:


Map validComponentNamesByRequestType = [
"Sales": ["Purchase", "Return"],

if (!requestTypeName) {
//no requestTypeName is available at this time (also happens when creating issues from Jira instead of the portal
def validComponentNames = validComponentNamesByRequestType[requestTypeName]
def validComponent = issueContext.projectObject.components.findAll { in validComponentNames }

Hi, @Peter-Dave Sheehan sorry to bother you. How can I not show these components in the Tech Support request type? Right now it is working fine with Sales where I can see only components that I add in the script, but is there a way that those components are not shown in any other request type, like Tech Support. In Tech Support and another request type, I can see "Purchase" and "Return" too. Right now in Tech Support and other request types, I can see all components, but I don't those components display there. Is there any way that any components display in Sales request type, those components should not display in any other request type?


Thank you for your help.

Just to confirm:

Sales Request Type => only show "Purchase" and "Return" component in the list

All other request type => Hide "Purchase" and "Return" components from the list

You could just add all your other request types here:

Map validComponentNamesByRequestType = [
"Sales": ["Purchase", "Return"],
"Tech Support": ["ComponentA", "ComponentB", ...],

Or if you don't want to have to update this script each time you add components or request tyes, you can have something like this:

Map exclusiveComponentByRequestType = [
"Sales": ["Purchase", "Return"],

if (!requestTypeName) {
//no requestTypeName is available at this time (also happens when creating issues from Jira instead of the portal
def validComponents = issueContext.projectObject.components
if (exclusiveComponentByRequestType.containsKey(requestTypeName)) {
//this is the same as earlier script version. Just with different variable names
def validComponentNames = exclusiveComponentByRequestType[requestTypeName]
validComponents = validComponents.findAll { in validComponentNames }
} else {
//for the case where the request type is not in the exclusionlist, we look at each request types that have exclusions and we remove those items from the valid list
exclusiveComponentByRequestType.each{rtName, componentNames->
if(rtName != requestTypeName){
validComponents.removeAll { in componentNames }
Like Shah Baloch likes this

Thank you so much @Peter-Dave Sheehan, I tried the first method by mapping other components with other request types and it didn't work. I just realized I didn't add those request type I Mapping list, I had just Sales one.

Your second script would work better for me. Thank you again for helping. have a nice weekend.

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events