- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 01:10 AM
I want to convert business rule to fix script.
Below is the business rule:
(function executeRule(current, previous /*null when async*/ ) {
var ip = current.ip_address;
var ips;
if (current.ip_address.startsWith("192.168.0.")) {
current.u_network_zone = "DC - CDE";
ips = ip.substring(10);
if (ips < 128) {
current.u_dc = "Seoul";
} else {
current.u_dc = "Jukov";
}
current.u_is_connect_to_internet = 0;
current.u_is_use_card_information = 1;
current.u_is_deliver_user_information = 1;
current.u_va_total_score = 2;
}
})(current, previous);
What this business rule do is filters CI's ip address and sets some fields value to certain value.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 02:07 AM
Hi,
You can use below script,
var ips,ip;
var grCMDB=new GlideRecord("cmdb_ci_server");
grCMDB.addEncodedQuery("ip_addressSTARTSWITH192.168.0.");
grCMDB.query();
while(grCMDB.next()){
ip = grCMDB.ip_address;
ips = ip.substring(10);
if (ips < 128) {
grCMDB.u_dc = "Seoul";
} else {
grCMDB.u_dc = "Jukov";
}
grCMDB.u_network_zone = "DC - CDE";
grCMDB.u_is_connect_to_internet = 0;
grCMDB.u_is_use_card_information = 1;
grCMDB.u_is_deliver_user_information = 1;
grCMDB.u_va_total_score = 2;
grCMDB.update();
}
Let me know if you have any further queries.
Please mark this as Correct or Helpful if it helps.
Thanks and Regards,
Abhijit
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 03:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 02:07 AM
Hi,
You can use below script,
var ips,ip;
var grCMDB=new GlideRecord("cmdb_ci_server");
grCMDB.addEncodedQuery("ip_addressSTARTSWITH192.168.0.");
grCMDB.query();
while(grCMDB.next()){
ip = grCMDB.ip_address;
ips = ip.substring(10);
if (ips < 128) {
grCMDB.u_dc = "Seoul";
} else {
grCMDB.u_dc = "Jukov";
}
grCMDB.u_network_zone = "DC - CDE";
grCMDB.u_is_connect_to_internet = 0;
grCMDB.u_is_use_card_information = 1;
grCMDB.u_is_deliver_user_information = 1;
grCMDB.u_va_total_score = 2;
grCMDB.update();
}
Let me know if you have any further queries.
Please mark this as Correct or Helpful if it helps.
Thanks and Regards,
Abhijit
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 02:10 AM
Hi Abhijit, this one worked. Thanks a lot.