- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2017 10:56 AM
Hello,
I cannot figure out how to get this "if" statement to work in a client script. I know it's a syntax issue, but I cannot figure it out.
This works:
if ((risk == '') && (changeType != 'Standard')) {
g_form.removeOption('state',2); // Sumbitted
}
This does not work (throws a compiler syntax error:
if ((risk == '') && (changeType != 'Standard')) || ((risk == '') && (changeType != 'Emergency')) {
g_form.removeOption('state',2); // Sumbitted
}
This does not work (Submitted option is removed)
if (((risk == '') && (changeType != 'Standard')) || ((risk == '') && (changeType != 'Emergency'))) {
g_form.removeOption('state',2); // Sumbitted
}
I also tried splitting it into two if statements, and that did not work.
Any ideas?
Thanks,
Laurie
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2017 11:50 AM
WAIT!!!! Hang on to your hats ladies and gentlemen!!!
The solution is do not use "||" ! Use "&&"!
Thanks,
Laurie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2017 01:14 PM
Curious to know what you're actually checking for.
It seems that risk needs to be empty, and change is not "emergency" or "standard" - in which case, the && will be needed (because being one of those change types would meet the "not" criteria of the other).
Would it be easier to ask: if risk is empty and change is normal? Or do you have additional change types outside of those three options?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2017 02:01 PM
Hi David,
We do have one additional change type called Expedited.
Thanks,
Laurie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2017 10:26 AM
In which case, your condition can be reduced to:
if (risk == '' && changeType != 'Standard' && changeType != 'Emergency' )
.. but I think you mentioned that in your answer, anyway.