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

Scriptrunner: Validator field required by value of another field

I want to make a field (Company and Role) mandatory in the Create screen if another field (Application Area)(select list) has the value "SL SAP ECC”.


I use a validator on transition Create.


import com.onresolve.jira.groovy.user.FieldBehaviours

import groovy.transform.BaseScript


@BaseScript FieldBehaviours fieldBehaviours


def ApplicationAreaField = getFieldById(getFieldChanged())

def CompanyandRoleField = getFieldByName("Company and Role")


String ApplicationAreaValue = ApplicationAreaField.getValue()


if (ApplicationAreaValue == 'SL SAP ECC') {


} else {




But JIRA gives the report about that field, regardless of which value is chosen in the select list.


Where do I make the mistake?

2 answers

1 accepted

0 votes
Answer accepted

Adaptavist told me the following:


To achieve what you are asking you need to use a behaviour instead of a validation.

Can you try this code as a server side script for a behaviour on the "Application Area" field:


def ApplicationAreaField = getFieldByName("Application Area")
def CompanyandRoleField = getFieldByName("Company and Role")

ArrayList ApplicationAreaValue = ApplicationAreaField.getValue() as ArrayList

if (ApplicationAreaValue.contains("SL SAP ECC")){ 
} else{ 

 And this works for my situation

1 vote

Hi Marco,

If we are talking about a transition validator, the script should be something like this:

import com.atlassian.jira.component.ComponentAccessor
import com.opensymphony.workflow.InvalidInputException

def cfMgr = ComponentAccessor.getCustomFieldManager()
def companyAndRole = issue.getCustomFieldValue(cfMgr.getCustomFieldObjectByName("Company and Role"))
def applicationArea = issue.getCustomFieldValue(cfMgr.getCustomFieldObjectByName("Application Area"))

if(!companyAndRole && applicationArea.getValue().equals("SL SAP ECC")){
throw new InvalidInputException("Company and Role field is required!")
return true

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events