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

How can I get this simple scripted validator to work?

Matthew Mallard December 8, 2021


I have a simple scripted validator set on one of the transitions in my Story workflow. The goal is to prevent the transition if the Story has the "Type" custom field set to "Software" and the "Test Criteria" custom field is blank. Here's what I got which isn't working.

(cfValues['Type'] != 'Software') || (cfValues['Type'] == 'Software' && cfValues['Test Criteria'])


1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Peter-Dave Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 8, 2021

If your "Type" custom field is a select of some kind, you might want to try it like this:

def typeValue = (cfValues['Type'].value
(typeValue != 'Software') || (typeValue == 'Software' && cfValues['Test Criteria'])

That's because the cfValues data type will depend on the selected field. If it returns an "Option" object, then you have to look inside that object to get the text value (as oposed to the option Id).

Also, a bit of free advice... you might want to consider renaming that "Type" field to something more specific. Since "type" is a keword shortcut in JQL meaning the same as "issueType".

Now, if you try to write a JQL like

type = story 

You may have inconsistent behaviour, or you will be forced to use the "cf[12345] = Software." format.

Matthew Mallard December 12, 2021

Final version:

import org.apache.log4j.Level
import org.apache.log4j.LogManager
import org.apache.log4j.Logger

Logger rootLogger = LogManager.rootLogger
rootLogger.level = Level.INFO

if ( == 'Story') {
def typeValue = cfValues['Type']?.value
def testCriteria = cfValues['Test Criteria']?.value"Type: ${typeValue}, Test Criteria: ${testCriteria as Boolean}")

(typeValue != 'Software') || (typeValue == 'Software' && testCriteria)
} else {
AUG Leaders

Atlassian Community Events