You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
G'evening,
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'])
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 (issue.issueType.name == 'Story') {
def typeValue = cfValues['Type']?.value
def testCriteria = cfValues['Test Criteria']?.value
log.info("Type: ${typeValue}, Test Criteria: ${testCriteria as Boolean}")
(typeValue != 'Software') || (typeValue == 'Software' && testCriteria)
} else {
true
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.