Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Transition should be blocked on Duplication selection of Custom Fields value

PLaksh11
Contributor
August 22, 2024

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)

1 answer

0 votes
Simon König
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 22, 2024

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 %}

Simon König
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 22, 2024

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

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events