Hello Community
I have 3 custom fields which are Multi select drop down. All 3 custom fields displays Same values. When User select Same value in more than 1 custom field and do the transition then its should not allow user to do the transition. Is there any way that i can use Jira validators to validate the duplicates and display the Error message.
Ex: Custom Field 1: Apple, Orange
Custom Field 2: Mango, Orange
Custom Field 3: Banana, Strawberry
In above example user selected Orange in 2 custom Fields. So when user do the transition It should check field values in all 3 custom fields and if they found duplicates then it should display error message and blocks the Transition.
Note: We are using Jira Cloud with Jira Misc Workflow Extensions (JMWE)
Hello,
I think this should be possible with a Validator Script using JMWE:
I have not tested it, but you could use something like this:
First concat your values into a list :
{% set values1-3 = [] %}
{% set values1-3 = values1.concat(multiselectcustomfield1) %}
(You could also do this depending on the selected field via:
{% if field1 %}
{% set 1values1 = values1.concat(multiselectcustomfield1) %}
...
)
Then you should check if there a duplicates, this can be done like this:
1. group by -> Groups your list by unique value
2. Filter over the unique group and retain only duplicates:
filter(g => g|length > 1)
3. Check if the filter returned something: | length > 0
In sum:
{% set duplicates = all_values | groupby | filter(g => g|length > 1) | length > 0 %}
You now can check with a simple if statement if duplicates exist and act accordingly:
{% if duplicates %}
This transition is blocked: duplicate values were found in the custom fields.
{{ false }}
{% else %}
{{ true }}
{% endif %}
In short:
Parse your fields into a single list, check if 1 item in that list exists multiple times, if that is the case act accordingly.
Regards
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.