- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2021 05:57 AM
Hi Community
I'm after a bit of help with a switch case statement that i'm working on at the moment. I have a number of subnets that will be discovered in a schedule. I need to populate the owned by and managed by teams along with some other details. Across the subnets the second octet is unique, so .32 is business intelligence systems and .48 directory systems.
I'm just testing one department at the moment and its not adding the ownedBy team but its doing everything else fine. *Note: i've removed the actual sys ids from this script.
Thank you
(function executeRule(current, previous /*null when async*/) {
var ownedBy;
var tempIP = current.ip_address.split(".");
var tempIPLast = parseInt(tempIP[3]);
var tempIPThird = parseInt(tempIP[2]);
switch(tempIPThird) {
case (tempIPThird > 31 && tempIPThird < 48):
ownedBy = 'sys_id for team'; //Business Intelligence Systems
break;
}
current.u_dr_priority = 'P4';
current.used_for = 'Development';
current.u_classification = 'Internal Use Only';
current.managed_by = 'sys_id for team'; //Technical Services South
current.owned_by = ownedBy;
})(current, previous);
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2021 10:30 AM
Hi Marvin,
You'll find that if you change your switch statement to switch(true) the case statement syntax you are using will work. If you haven't done so, you could also add some logs to confirm the value of tempIPThird, and if ownedBy is getting set correctly. Have fun!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2021 10:30 AM
Hi Marvin,
You'll find that if you change your switch statement to switch(true) the case statement syntax you are using will work. If you haven't done so, you could also add some logs to confirm the value of tempIPThird, and if ownedBy is getting set correctly. Have fun!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2021 09:04 PM
Thank you Brad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2021 03:39 AM
You are welcome.