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

This widget could not be displayed.

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

This widget could not be displayed.

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

This widget could not be displayed.
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 Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published Jul 25, 2018 in Marketplace Apps

Jira Cloud and Bitbucket Cloud Integration with Microsoft Teams

One of the newest products in the Microsoft family - Microsoft Teams,  is a chat-based hub for teamwork that integrates all the people, content, and tools your team needs to be more engaged and ...

730 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