- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2017 03:33 AM
Hi All,
Hopefully an easy question; i need to script an if condition to say active = true and state is not 6, 7 or 8. What's the best way to write this, can i comma-separate options or do i need to write out each state individually? I tried option 1 below and it didn't work so not really sure where to go from here.
if(active = true && state != 6 && state != 7 && state != 8){
//stuff here
}
if(active = true && state != 6, 7, 8){
//stuff here
}
if(active = true && state != 6 || 7 || 8){
//stuff here
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2017 03:37 AM
Hi David,
Try add one more bracket before state and it will work.
if(active = true && (state != 6 && state != 7 && state != 8)){
//stuff here
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2017 03:36 AM
- if(active = true && (state != 6 || state != 7 || state != 8){
- //stuff here
- }
This is the correct way

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2017 03:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2017 04:06 AM
Hmm this doesn't seem to be working for me. I have this on an onLoad client script that is returning resolution categories depending on various conditions. The script below clears options and then populates the list with an array produced via a GlideAjax, i need to stop this from running when the ticket is in any one of 3 resolved/closed states. I've tried the OR conditions below and i've tried them as AND (&&) as well but neither way seems to work. If i just say && state != 6 if works fine for that state...
if(response.retail == 'true' && type == 'Incident' && (state != 6 || state != 7 || state != 10)){
g_form.clearOptions('close_code');
g_form.addOption('close_code', '', '-- None --', 0);
var incident = response.incidents.split(",");
for(var i =0; i<=incident.length; i++) {
g_form.addOption('close_code', incident[i], incident[i]);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2017 04:11 AM
Actually scratch that, it has worked with the below syntax. it has also highlighted some missing mandatory field provisions in one of my resolution states!!
if(response.retail == 'true' && type == 'Incident' && (state != 6 && state != 7 && state != 10)){
Thanks all for the input