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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Proper way to use JMWE Validators with select list custom field Edited

Hello. I'm trying to do the following using JIRA Misc workflow extensions (JMWE) validators as a bit of an approval process. Basically if a field (10059, multi select list) is NOT set to None (which is the default no value for this field by JIRA). Then it needs to have one of the few people in the select list (10057) to pass validation.  Here is the basic expression that I thought  would work:

 

!!issue.customfield_10059 && issue.customfield_10059.some(it => it.value != "None") &&
!!issue.customfield_10057 && issue.customfield_10057.value == "a value in the list"

 

I tried the inverse of some of the logic above, but I cant see to get it work. It seems to always through the validation error, or never throw it. I'm pretty sure I' missing something simple, but I'm new to these type of expressions. 

 

As a bonus, it'd be nice to allow for a few values out of the list in 10057 allow it to pass validation (it'd be 3 names out 10 in that list. Something like  10057.value.containts("Approver 1", "Approver 2", "approver 3"). 

1 comment

Hi @Daniel Burris 

First of all, is "None" an actual option you have configured on your multi-select field, or does it denote that no value is selected? I assume the latter.

In that case, the internal value of the field is... null. 

Then the problem is with your logic. The Build-your-own validator should pass if either customfield_10059 is empty or (if it isn't empty) customfield_10057 has a desired value. So the code should be:

!issue.customfield_10059 || !!issue.customfield_10057 && issue.customfield_10057.value == "a value in the list"

 And for multiple acceptable values:

!issue.customfield_10059 || !!issue.customfield_10057 && ["val1","val2","val3"].includes(issue.customfield_10057.value)

Comment

Log in or Sign up to comment
TAGS

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you