Unable to get Simple Validation to Work

Sarathi Chatterjee January 22, 2018

Hi 

I am trying to get a validation where when Resolving an issue if the value of the multi select list contains "Change - Failed or partially failed Production Release", then the user must enter the CR Ref. field, for which I am using the query below 

cfValues['Source of Incident']*.value.contains("Change ? Failed or partially failed Production Release") || cfValues['CR Ref.']

 

based on your link  Here

But the problem is that with my query gets fired  for any value selected.

Can you please tell me what I am doing wrong 

Thanks 

 

 

 

3 answers

1 accepted

0 votes
Answer accepted
Stephen Cheesley _Adaptavist_
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.
January 24, 2018

Hi Sarathi,

There were a couple of issues with your given script:

  • Condition Typo - I noticed that in your description the option you wanted to pickup started "Change - ", but your actual condition in your script was "Change ? ". Your script needs to match the option you are validation on exactly.
  • Improper negation - This will return true, which means that nothing else will pass. This is the opposite condition of what you are looking for. You can fix this by negating the entire statement
  • OR rather than AND - I noticed that in your script you are writing "If the option is selected OR there is a reference". What your requirement states is something different (i.e. "If the option is selected AND there is not a reference")

I've taken the liberty of correcting these and putting together a working validation:

!(cfValues['Source of Incident'] &&
cfValues['Source of Incident']*.value?.contains("Change - Failed or partially failed Production Release") &&
!cfValues['CR Ref.'])

I hope this helps!

Steve

0 votes
Jenna Davis
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.
January 22, 2018

Hello, 

I tested out the same query as you (your first one) and didn't have any trouble getting it work as how you described wanting with the latest version of ScriptRunner. 

What version of ScriptRunner are you on? 

Jenna

Sarathi Chatterjee January 22, 2018

We are running 5.2.2 

Thanks 

Jenna Davis
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.
January 22, 2018

Would you be able to submit a support request on the ScriptRunner support portal? We can get information from you easier and more securely there and hopefully get this issue solved for you quickly. 

Jenna

0 votes
Sarathi Chatterjee January 22, 2018

I have also tried the following with the same result 

 

cfValues['Source of Incident']*.value.contains("Change ? Failed or partially failed Production  Release") && cfValues['CR Ref.']

 

 

cfValues['Source of Incident']*.value == ("Change ? Failed or partially failed Production Release") || cfValues['CR Ref.']

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events