How to import packages in Validator?


I am new to Scriptrunner.

I want to do validation on 2 dependent custom field. so basically I want to check if the "Urgent" is checked (check-box type) then only The "Reason" (text field) should appear and be Required.

I wanted use to Behavior initially so I wrote something like this:

log.debug "Debugging..."
def urgent = getFieldById ("customfield_10503")
def reason = getFieldByName ("customfield_10502")
def value = urgent.getValue()
log.debug "reason11: " 
if (value == true) {
  log.debug "reason22: " //+ value
} else {
  log.debug "reason33: " //+ value

But based when I am using this on Creation page, basically there is no listener to detect if the user has check the box or not and it will pass the "False" value to the If-else.


Then I decided to use Validator to do that on Create transition but I am unable to use

import com.atlassian.jira.issue.fields.DefaultFieldManager;
def urgent = getCustomField('customfield_10503')

and it give me Cannot find matching method Compile error.

Can anyone give me any advise?

1 answer

This widget could not be displayed.

Hi Adin,

You can import the ComponentAccessor and get all the managers from there 

import com.atlassian.jira.component.ComponentAccessor

example, you can get the custom field manager :

def customFieldManager = ComponentAccessor.getCustomFieldManager()

and then you can retrieve the custom field 

def cf = customFieldManager.getCustomFieldObjects(issue).find
{ == 'Urgent'}

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

137 views 2 0
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you