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

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

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

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!

Leaderboard

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
4,558,710
Community Members
 
Community Events
184
Community Groups

How can I get this simple scripted validator to work?

Edited

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'])

 

1 answer

0 votes
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Dec 08, 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.

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events