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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 30, 2018 in Marketplace Apps

Three tips for boosting your board's efficiency with Story Maps

Trello is one of the most effective tools for driving your sprints. It's customizable for every Agile team and product owners and Scrum masters (SM) love it. However, Agile teams often struggle with:...

844 views 2 9
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