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

Simple Scripted Validator - "OR"


I'm using Adaptavist Simple Scripted Validator to check the below on create:


A). I have a field "Global" - if a user fills it in as Yes, I want them to be required to fill out field "Users"

B). If a user fills in global = no, they have to fill out one of either Users, User Types, or Dataset. 


I have the script for A (below). How do I add in the script for B? Basically I want an either/or statement


cfValues['Global']?.value != 'Yes' || cfValues['Users']

1 comment

You could try something like this:

if(cfValues['Global']?.value == 'Yes'){
return (cfValues['Users'])
} else {
return cfValues['Users'] || cfValues['User Types'] || cfValues['Dataset']

 Or you could use a custom validator instead and target the error message based on the condition (cfValues is not available, so you'll need some code to read those values):

import com.atlassian.jira.component.ComponentAccessor
import com.opensymphony.workflow.InvalidInputException
def cfm = ComponentAccessor.customFieldManager

def globalCf = cfm.getCustomFieldObjectByName('Global')
def usersCf= cfm.getCustomFieldObjectByName('Users')
def userTypesCf= cfm.getCustomFieldObjectByName('User Types')
def datasetCf= cfm.getCustomFieldObjectByName('Dataset')

def globalVal = issue.getCustomFieldValue(globalCf)?.value
def usersVal = issue.getCustomFieldValue(usersCf)
def userTypesVal= issue.getCustomFieldValue(userTypesCf)
def datasetVal = issue.getCustomFieldValue(datasetCf)

if(globalVal == 'Yes' && !usersVal){
throw new InvalidInputException(usersCf.hiddenFieldId, "This field is required when Global = Yes")

if(globalVal == 'No' && !usersVal && !userTypesVal && !datasetVal ) {
throw new InvalidInputException(globalCf.hiddenFieldId, "When you select No, you must complete either 'Users', 'User Types' or 'Dataset'")


Come to think of it.. it might be easier to have 2 separate simple scripted validation configurations and target the message that way.. 


Log in or Sign up to comment
Community showcase
Published in Jira Software

Upcoming changes to epic fields in company-managed projects

👋 Hi there Jira Community! A few months ago we shared with you plans around renaming epics in your company-managed projects. As part of these changes, we highlighted upcoming changes to epics on...

14,625 views 37 46
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