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").
it's similar to what I shared earlier:
!!issue.customfield_10000 ||
!!issue.customfield_10010 && !["N/A","No"].includes(issue.customfield_10010.value)
&& !!issue.customfield_10011 && !["N/A","No"].includes(issue.customfield_10011.value)
&& !!issue.customfield_10012 && !["N/A","No"].includes(issue.customfield_10012.value)
&& !!issue.customfield_10013 && !["N/A","No"].includes(issue.customfield_10013.value)
where customfield_10000 is the ID of the Reason field, and customfield_10010...customfield_10013 are the IDs of the four dropdown fields.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @David Fischer , Seems you are every were for the JMWE logics.
Can you please help me here, we have four dropdown fields with values Yes, No , N/A, other and have a text field with name Reason.
Here when ever the field Reason is null(Empty) then the values of the four fields ( Field 1, field 2, field 3 , field 4 ) values should not be equal to N/A or No.
Can you please provide Build-your-own (scripted) Validator expression in create screen.
Thanks in advance for the help
Regards,
Ajay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @David Fischer , one more help please,
I want to set the A drop down field values to no based on another dropdown field values.
If the field A is set to yes then second field should select the No value. tried with below code but not able to achieve the required
issue.customfield_10007.value || !! issue.customfield_10007.value == "YES" && issue.customfield_10032.value == "NO"
Thanks again,
Ajay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you please reformulate you're requirements, I didn't quite get what you need.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@David Fischer , thanks for the prompt response,
Assume we have two dropdown fields A and B with same values Yes, No , N/A,
If Field A is set to Yes on create then field B should not accept the values Yes , N/A it should only accept the value No.
Hope it make sense now.
Thanks,
Ajay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think I understand the desired validation. The script would be:
!issue.customfield_10007 || issue.customfield_10007.value != "Yes" || issue.customfield_10032.value == "No"
(note that the values are case-sensitive)
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.