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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Validate Multi Select User Custom Field value against User CF value

Hello,

I am stuck with something which seems to be very easy but somehow I cannot figure it out. 

We want to have a Workflow validator during a transition that will check the following:
Single Select Custom Field (User Pickup) called Code Reviewer value does not exist in 
Developer(s) - Multi Select Custom Field (User Pickup). 
Example, if we have: 
Code Reviewer = John Smith
Developer(s)  = John Smith (may include more users eg. Peter Goosters, Dave Jones) 
The transition should throw an error. 

I am using Script Validator [ScriptRunner]  - Simple scripted validator and I tried the following without success:

cfValues['Developer/s'] != cfValues['Code Reviewer']
!(cfValues['Developer/s']*.value.contains(cfValues['Code Reviewer']?.value)) 
(cfValues['Developer/s'] as int) >= (cfvalues['Code Reviewer'] as int)  
 cfValues['Developer/s']*.value != cfValues['Code Reviewer']?.value

Any help Is highly appreciated. I guess I will need to write more complex code to extract the multiselect values and compare them with my single select fields but I don't know how. And also I don't know if because these are user field it's even more complicated :) 

Thanks in advance

1 answer

0 votes
Leo Community Leader Nov 10, 2020

Hi @TIS Admin,

I haven't run this snippet, but you may wish to try like below

cfValues['Code Reviewer']*.value in cfValues['Developer/s']*.value

 

BR,

Leo

Hi Leo, how this can be translated to validate that transition will proceed if there is no match? 
Something like? 

!(cfValues['Code Reviewer']*.value in cfValues['Developer/s']*.value)

 Or do I have to use if and throw exceptions? 

Leo Community Leader Nov 11, 2020

@TIS Admin ,

If you place this in condition then the transition button visible only if the condition passes

if you want to validate the values which is entered during transition using transition screen then you'll have to go with either validator or behaviour(I prefer behaviour in this scenario)

 

BR,

Leo

Sorry, I was not clear enough. I want to allow the transition only if the value of Code Reviewer is not found in the Developer/s multi-select field. 

Leo Community Leader Nov 11, 2020

cool, this is pretty easy, place below snippet in conditions instead of validator

cfValues['Code Reviewer']*.value not in cfValues['Developer/s']*.value

if the condition fails, you'll see that particular transition hidden until the condition becomes true

 

BR,

Leo 

Unfortunately the transition is not allowed with this code :( 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.6.1
TAGS
Community showcase
Published in Jira

Announcing the waitlist for Jira Work Management

Hey there Cloud Community members! We’re excited to give you the first glimpse of the new home for business teams on Jira — Jira Work Management. Jira Work Management is the next generation of J...

874 views 14 20
Read article

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