Hi there. Using either ScriptRunner / JSU / JMWE, is there a way to satisfy the following conditions:
Fields:
Conditions:
Examples:
We've been able to make some progress to check use ScriptRunner's Regular expression validator [ScriptRunner] to be able to make something like this happen with the following:
^https:\/\/google.com\/.*.pdf
However, I struggle to expand the script above to interact with another field. Any insights is appreciated!
with JMWE, you could use a Scripted (Groovy) Validator with code like this:
switch (issue.get("File Source")) {
case "Google": return issue.get("File Source URL") ==~ /^https:\/\/google.com\/.*.pdf/
case "Yahoo": return issue.get("File Source URL") ==~ /^https:\/\/yahoo.com\/.*.pdf/
default: return true //no check if another source
}
Hi David. Thank you the response! Is it also possible to conditionally display a different error message for each one (depending on the File Source value)?
Example:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Absolutely! Instead of returning a boolean value (true/false), you can return a String that will be the error message:
switch (issue.get("File Source")) {
case "Google": return issue.get("File Source URL") ==~ /^https:\/\/google.com\/.*.pdf/ ?: "The URL is not from Google"
case "Yahoo": return issue.get("File Source URL") ==~ /^https:\/\/yahoo.com\/.*.pdf/ ?: "The URL is not from Yahoo"
default: return true //no check if another source
}
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.