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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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 do I fetch the current Customer Request Type in Initialiser script in Behaviours? Edited

Hi all,

I'm trying to build an Initializer script in Behaviours that when the create issue (so should work with an issue create screen) window is opened (from the customer portal) reads the current Customer Request Type and hides/shows some fields. I'm having troubles in fetching the value of Customer Reuqest Type field. So far I have the current code:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()

def customField = customFieldManager.getCustomFieldObjectByName("Customer Request Type")"customField: " + customField)
def fieldConfig = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(fieldConfig)"options: " + options)

but at this stage it doesn't deliver any value in options when I open create issue window from customer portal:

2019-07-16 15:19:08,664 /rest/scriptrunner/behaviours/latest/jsd/jsd/validatorsByPid.json [c.o.j.groovy.user.FieldBehaviours] options: []
2019-07-16 15:19:08,663 /rest/scriptrunner/behaviours/latest/jsd/jsd/validatorsByPid.json [c.o.j.groovy.user.FieldBehaviours] customField: Customer Request Type

Any help?

3 answers


The only way I've found is using this:


It return the Customer Request Type ID.

I still have to write the code to retrieve the Request Type details that match this ID.

Hope this can help some other peoples and if someone have a better way, feel free to share.


Thank you very much.
getRequestTypeName () is broken and causes a crash in the script when the logged in user to SD is a client, not an actor.
You don't even know how much trouble you saved me.

Like Jean-François FORGET likes this

LoL @Jacek Zarzycki , thank you as well.

I switched to @Mazen AKIKI _Infosysta_  solution few days ago and didn't notice the bug you've just mentioned.


I definitely confirm that this:

String customerRequestTypeName = (getRequestTypeName())

Must be replaced by something like this:

import com.amundi.jira.ProjectPortal
import com.atlassian.jira.project.ProjectCategory

ProjectPortal projectPortal = new ProjectPortal(project)
String customerRequestTypeId = getFieldById("summary").getFieldBehaviours().properties.formContents.requestTypeId
String customerRequestTypeName = projectPortal.getRequestById(customerRequestTypeId.toInteger()).getName()

Note: I'm on Jira Software 8.5.6 + Jira SD 4.5.6 

In order for the script to work with both Jira Service Desk and Jira Core "Create" use this:

import static MyUtil.MyFunctions.RequestTypeName
RequestTypeName- Is my own function
This function convert diferente values like 

"New Server"

  It returns the string with the name "Request Name ABC" or ""

static com.atlassian.jira.issue.IssueFieldConstants.SUMMARY
String tmpRequest = ""
String RequestTypeValue = ""

try {
  def Summary = getFieldById(SUMMARY)
  tmpRequest = Summary.getFieldBehaviours().properties.formContents.requestTypeId.toString()
finally {
   RequestTypeValue = RequestTypeName(tmpRequest)

// User does not use Service Desk but Jira Core "Create" or "Edit"
// if you try validate tmpRequest  here it want work
if ( RequestTypeValue == "") { 
   try {
       def RT = getFieldByName("Request Type")
       tmpRequest = RT.getValue().toString()
   finally {
     RequestTypeValue = RequestTypeName(tmpRequest)

if (RequestTypeValue  == "Request Name ABC" ) {
  do something ...

 I'm on Jira Software 8.5.4 + Jira SD 4.5.4 

Like Jean-François FORGET likes this

Hi this suggestion worked for me if (getRequestTypeName() == 'IT Help')

hope this helps

It definitely helps.

So simple.... thanks a lot!

Suggest an answer

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

Why upgrade to Jira Service Management Premium?

We often have questions from folks using Jira Service Management about the benefits to using Premium. Check out this video to learn how you can unlock even more value in our Premium plan.  &nb...

163 views 0 4
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