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

How can I get this simple scripted validator to work?



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

0 votes

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.

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 {

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events