I have this JMWE script functional as a validator on a transition in a workflow. If the Tempo Account field matches this value then an error is thrown on the transition modal to ask the user to choose a different account. It works good by assuring that those issues with Account 123 are unable to pass.
!!issue.customfield_12440 && issue.customfield_12440.value != "Account 123"
I need to test for Account 123 or Account 789 in the Account field and throw the same error if either is false but I'm unable to combine this with a logical OR "||". I've tried various syntax, but the validation is always true for some reason so it lets issues, for example, with Account 123 or Account 789 through without blocking.
!!issue.customfield_12440 && issue.customfield_12440.value != "Account 123" || !!issue.customfield_12440 && issue.customfield_12440.value != "Account 789"
If I understand correctly, you really want an "and", not an or. Because you want the value to be different from Account 123 and to be different from Account 789
A shorter version of this condition is:
!!issue.fields.customfield_12440 && !["Account 123","Account 789"].includes(issue.fields.customfield_12440.value)
Hi David. This does not work since it throws the error for an issue with Account ABC when it should allow it through.
I need to invalidate either Account 123 OR Account 789 and display the error on the transition's modal, in my case, the Close Transition. If the issue's account equals one of these two values, I need it to block.
Examples:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am using the 'build your own script' validator if that matters...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, I overlooked the fact that this is a script for a workflow validator. Jira Cloud Conditions and Validators use Atlassian's Jira Expressions language and thus differ from Nunjucks that is used in JMWE post-functions. In particular, fields are accessed without ".fields". Therefore, the expression should be:
!!issue.customfield_12440 && !["Account 123","Account 789"].includes(issue.customfield_12440.value)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This works. That's good to know, David. As usual, I very much appreciate you and your product ;-).
-Paul
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.