Switch case statement in Business Rule

Marvin5
Tera Expert

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);

 

 

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

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!

 

 

View solution in original post

3 REPLIES 3

Brad Bowman
Kilo Patron
Kilo Patron

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!

 

 

Thank you Brad

You are welcome.