Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get Hidden field value or request type group in Behaviours?

Leo Community Leader Mar 28, 2021

Hi Team,

I want to show/hide fields based on the Group(request type) selected in the portal

but couldn't find a way

I tried pre-set value and hidden the field in jira request type configuration. that sets the value perfectly in issue creation. but unable to fetch the hidden field in behaviour script

and lead or suggestion would be much appreciated


Thanks in advance,


1 answer

0 votes

Hey Leo

Behaviours only gives you the request type name with getRequestTypeName()

There may be a simpler way ... but the only way I know how to get the full request type object (which includes a getGroups method) from it's name is to pull a couple of services and managers and string them together like this:

import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.atlassian.servicedesk.api.ServiceDeskManager
import com.atlassian.servicedesk.api.requesttype.RequestTypeService
@PluginModule ServiceDeskManager serviceDeskManager
@PluginModule RequestTypeService requestTypeService

def serviceDesk = serviceDeskManager.getServiceDeskForProject(issueContext.projectObject)
def queryBuilder = requestTypeService.newQueryBuilder()
def allRequestTyps = requestTypeService.getRequestTypes(null,
def requestType = allRequestTyps.find { == getRequestTypeName()

def groupNames = requestType.groups*.name
Leo Community Leader Mar 29, 2021 • edited

Hi @Peter-Dave Sheehan,

Thanks for your quick reply, I get below error hope you can assist me


I have SR 6.19.0 version and JSD 4.5.9, if that matters


Thanks in advance,


Static type checking errors are not always indicators of bad code. Just that the scriptrunner script editor can't confirm if the code is good or not.

In this case, the "requestTypeService.getRequestTypes" returns a "PagedResponse" object that could contain different kind of items. So the code checker can't know we expect RequestType scpecifically without telling it.

Groovy is dynamic by design and objects can be of varying types.

But if you really want to eliminate these sorts of errors, we can tell the editor what type of object we're deling with.

Add this import :

import com.atlassian.servicedesk.api.requesttype.RequestType

Then replace the last block with 

def allRequestTypes = requestTypeService.getRequestTypes(null,
def requestType = allRequestTypes.find {RequestType requestType-> == 'Incident'
} as RequestType
Leo Community Leader Mar 29, 2021

Hi @Peter-Dave Sheehan ,


This works awesome, but the problem is it returns all the groups requestType is involved

I want just one group through which customer has selected the request type


e.g. Group 1 --> INC

       Group 2 --> INC

If I opened INC through Group 1. I need the result just "Group 1" but the result is both 1 & 2 :( 




I don't think that's knowable.

If you examine the URL when you access the form from one group or another, you will see they are identical.

If that's a critical requirement, you will have to duplicate the request type and have each request type in a single group.

Leo Community Leader Mar 29, 2021

Thanks @Peter-Dave Sheehan

for your time and wonderful assistance :) 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira Service Management

JSM Jira Automation: How to Send SLA Breached Notifications

Hi Everyone, In   this tutorial,  we will show you how you can monitor an SLA, and send notifications before or after the SLA has been breached.   SLA Threshold Trigger The SLA t...

688 views 5 12
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you