1 answer

This widget could not be displayed.

No, because the order of validators does not matter.

Each validator is a simple yes or no question. If any one of them is a "no", the whole thing fails.

Think of baking a cake - you have validators like "do we have eggs", "do we have flour", and "do we have sugar" and "do we have butter".  If any of them are "no", the transition from "gathering ingredients" to "making cake" fails.  It is irrelevant what order you check for them.

I suspect your question is about a conditional flow of validation - if <something> = X, then check Y, but if <something> = Z, then do no further checks.  Is that what you're trying to do?

I just want to have the same order as the fields in the screen. I can add a new field in the beginning of the screen but the new validation will be executed as the last one.

I just want to have the same order as the fields in the screen. I can add a new field in the beginning of the screen but the new validation will be executed as the last one.

But the order does not matter.  The only place you see the order is when you're an admin editing the workflow.

Assume you have many fields: first field, second field, third field.... When a user fills the form to create the issue and there are validation errors, he will have the alerts to fix the validation errors in the order that are the validations. So the validation for the 10th field may be before the validation of the first field.

Ok, that's a good reason for it, but JIRA doesn't think that way, it just fails all validation without order, because in most cases, it doesn't matter.

You could remove all the validators and re-add them in field order, but there is a better solution.

Write your own validation script to replace the set of canned ones you're using now.  You can check every field you want to in one script, and return an error to the user listing all the fields they've missed or got wrong in one go.  That's better for the user too - if they've made five mistakes, they don't have to correct them one at a time.

Do I have to use Custom script validator for my own validation script insted of Simple scripted validator ? Where can I find an example?

Yes, that's correct.

The snippet I use as a base checks that a value is set if the issue type is bug:

if (issue.issueTypeObject.name == 'Bug' & cfValues['DemoSelectList']?.value == 'Capital'){
        throw new InvalidInputException("Something to tell a user what went wrong")
    return false
}
return true

Hi again!

This is my snippet. I get an error for "InvalidInputException". Do I have to do some imports?

// Import Regex
import java.util.regex.*;
// Construct The Pattern to Match on
Pattern pattern = Pattern.compile("^([0-9]{1,6})\$");
// Check if the Order Number Field is a match

if (cfValues['Order Number'] == null || pattern.matcher(issue.getCustomFieldValue(customFieldManager.getCustomFieldObjectByName("Order Number")))){
throw new InvalidInputException("Please enter a valid number!")
return false
}
return true

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Aug 06, 2018 in Jira Service Desk

A is for Activate: Share your top Jira Service Desk onboarding tips for new users!

Hi, everyone! Molly here from the Jira Service Desk Product Marketing Team :).  In the spirit of this month's  august-challenge, we're sourcing stories of Jira Service Desk activation fro...

580 views 25 15
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you