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 do I use ScriptRunner to populate Customer Request Type when a specific Issue Type is created


I am trying to implement a solution using Adaptavista ScriptRunner and am running into some difficulties making the code work as expected. 

System: JIRA 7.11.1

JIRA Service Desk

Scenario/ Use Case: When creating a new issue from the JIRA channel (not the service desk Customer Portal channel) on the create screen I would like to be able to edit the "Customer Request Type" field using ScriptRunner to select a specific "Customer Request Type" when the issue creator selects a specific "Issue Type". If customer selects issue type A, then Customer Request Type A is also selected. In addition I would like to always hide the "Customer Request Type" field on the create issue screen so that users cannot change it.

I am running into difficulty as the "Customer Request Type" doesn't seem to conform to any of the field types I have previously used ScriptRunner on (Select List, Multi Select List, Radio Button). I am sure this something that can be handled in 6 to 8 lines of code, but I am not having any luck at all with getting the expected results. 

Any help or guidance you can provide is greatly appreciated. 

2 answers

I was able to use the Initialiser to hide the field "Customer Request Type" for the create screen, however I am not able to figure out how to set the field value for the Customer Request field. Any help on what I am doing wrong would help.  The error I am getting is on the very last line of this code (see code block for complete example) : issue.setCustomFieldValue(tgtField, requestType)

def fieldToHide = getFieldByName("Customer Request Type")
def IssueType = getFieldByName("CF Request")
def optionValue = IssueType.getValue().toString()


if (optionValue == 'Non-template') {

import com.atlassian.jira.component.ComponentAccessor

def QuantumRequest = "key/444099ab-e1bd-4a9d-8f09-11c93f104d15"

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def tgtField = customFieldManager.getCustomFieldObjectByName("Customer Request Type")

log.debug("Customer Request Type Custom field Id: ${tgtField.getId()}")

def requestType = tgtField.getCustomFieldType().getSingularObjectFromString(CFRequest)
issue.setCustomFieldValue(tgtField, requestType)


Trying to help myself out as bit as this is a pressing issue I need solved. Looks like Customer Request Type doesn't conform to other field types, so I have to use a different methodology to reference that field:

From the Scrip Console:

import com.atlassian.jira.component.ComponentAccessor

def issue = ComponentAccessor.issueManager.getIssueByCurrentKey("KEY-###")
def cf = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Customer Request Type")

From there the results provide the field name:


I found some more details here to assist with the Customer Request Type field

Suggest an answer

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

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across their  Jira Cloud instance.  ...

553 views 15 18
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