Unable to get Simple Validation to Work

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

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

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.']

0 vote
Jenna Davis Community Champion Jan 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

We are running 5.2.2 

Thanks 

Jenna Davis Community Champion Jan 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

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published 9 hours ago in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

34 views 0 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you