Easy Client Script "OR" Condition Not Working

Laurie Marlowe1
Kilo Sage

Hello,

Easy points!!   I cannot figure out what is wrong with this client script!   I'm trying to allow the "Submitted" option on the state field for a Change Request if the Type field Standard or Emergency.

Originally, the script checked for risk = '' && changeType != 'Standard' " which worked fine.

All I did was add " || changeType != 'Emergency' " in the script, and now it removes the Submitted option.   I don't want it to be removed!   I have tried every combination I can think of for the parenthesis, splitting out the "if" conditions, and so forth.   What am I missing?

Capture.JPG

Thank you in advance,

Laurie

1 ACCEPTED SOLUTION

drjohnchun
Tera Guru

Please try



if (risk == '' && !(changeType == 'Standard' || changeType == 'Emergency')){



Hope this helps.



Please feel free to connect, follow, mark helpful / answer, like, endorse.


John Chun, PhD PMP see John's LinkedIn profile

visit snowaid


ServiceNow Advocate

Winner of November 2016 Members' Choice Award


View solution in original post

4 REPLIES 4

drjohnchun
Tera Guru

Please try



if (risk == '' && !(changeType == 'Standard' || changeType == 'Emergency')){



Hope this helps.



Please feel free to connect, follow, mark helpful / answer, like, endorse.


John Chun, PhD PMP see John's LinkedIn profile

visit snowaid


ServiceNow Advocate

Winner of November 2016 Members' Choice Award


Just to add to it, Boolean logic-wise, these two are equivalent



R && !(S || E) == R && !S && !E



so you can use whichever you like. As for me, the first one is a bit easer on my brain when there are multiple OR conditions.


Mihir Mohanta
Kilo Sage

changeType != 'Standard'|| changeType != 'Emergency'



this condition will always return true.



I think your condition should be



risk == '' && changeType != 'Standard' && changeType != 'Emergency'




Thanks


djoodjii
Kilo Expert

Hi,


if (risk == '' && (changeType != 'Standard' && changeType != 'Emergency'))