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

Scriptrunner validator not working

Gavin Minnis July 17, 2018

I'm trying to restrict a transition when three conditions are true at the same time:

  1. the field "Order Parts" has a value of 'Yes'
  2. the field "Disposition" has a value of EITHER a) 'Rework at OEM & labor $ OEM - (FB)' b) OR 'Rework at OEM - (FR)'
  3. the field "Parts Ordered" has no value

I wrote the following script which is always stopping the transition. It is not allowing the transition to occur when #3 above has a value. For context, I'm using a post function to apply a value of 'Yes' to the field "Parts Ordered" once the sub-task has been closed.

 

if (cfValues['Order Parts']?.getValue() == 'Yes' & (cfValues['Disposition']?.getValue() == 'Rework at OEM & labor $ OEM - (FB)' | cfValues['Disposition']?.getValue() == 'Rework at OEM - (FR)') & cfValues['Parts Ordered'] == null){

return false
}

 

2 answers

1 accepted

0 votes
Answer accepted
Payne
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.
July 18, 2018

You are not returning a value of true if the conditional check fails. Try

if (cfValues['Order Parts']?.getValue() == 'Yes' & (cfValues['Disposition']?.getValue() == 'Rework at OEM & labor $ OEM - (FB)' | cfValues['Disposition']?.getValue() == 'Rework at OEM - (FR)') & cfValues['Parts Ordered'] == null){

return false
}
return true
Gavin Minnis July 18, 2018

Perfect. That worked. Thank you!

0 votes
Alexey Matveev
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.
July 17, 2018

Hello,

Try like this:

if (cfValues['Order Parts']?.getValue() == 'Yes' && (cfValues['Disposition']?.getValue() == 'Rework at OEM & labor $ OEM - (FB)' || cfValues['Disposition']?.getValue() == 'Rework at OEM - (FR)') && cfValues['Parts Ordered'] == null){

return false
}
Gavin Minnis July 18, 2018

Hi Alexey,

 

I tried your code and it still wasn't working as expected. I am getting a validator error even when the field "Parts Ordered" has a value of 'Yes'.

Also, I see that your recommended code only changed & to && and | to || but that seems like incorrect login to me. If I understand correctly, by using a double & or double | you are using login that says STOP checking the login as soon as you get to an operator that meets the condition. But I need ALL 3 conditions to be true for the validator to kick in.

Gavin Minnis July 18, 2018

Also to be clear, I'm using a Simple Scripted Validator.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events