- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2021 12:19 AM
Hi,
I have written a after BR to change the operational state and status of CI to operational and Install on most recent discovery is done and the Ci is discovered within 10 days span.
It isn't changing state and Operational status of CI.Is Business rule configured correctly?
TIA.
Solved! Go to Solution.
- Labels:
-
Discovery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2021 06:42 AM
Hello Sai,
Thankyou for your response.
After multiple try. Below script worked for me.
var gr = new GlideRecord("cmdb_ci_win_server");
gr.addQuery("sys_id", "mention sys id");
gr.query();
while(gr.next())
{
var co = gr.last_discovered;
var dt = new GlideDateTime();
var ageing= gs.dateDiff(co, dt, true);
var ageingDurInMin = Math.round(ageing/(60*60*24));
gs.print(ageing);
gs.print(ageingDurInMin);
if(ageingDurInMin < 7){
gr.operational_status= 1;
gr.install_status= 1;
gr.update();
}
}
Regards,
AB.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2021 01:47 AM
Hi
Please try this, configure this as per your requirement
sys_updated_onRELATIVELT@dayofweek@ago@10 -- I got this from filter condition at table list, Condition is "updated relative before 10 days ago" and copied that query in script
var gr = new GlideRecord('cmdb_ci_win_server');
gr.addEncodedQuery('sys_updated_onRELATIVELT@dayofweek@ago@10^sys_id='+current.cmdb_ci_win_server);
gr.query();
while(gr.next()){
gr.setValue('install_status','1');
gr.setValue('operational_status','1');
gr.update();
}
Please mark my answer as helpful/correct, if applicable
Best regards, Sai Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2021 05:55 AM
Hello Sai,
I tried executing above script .Still there is no change in the CI.I am not sure why BR is not working.
Regards,
AB.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2021 06:42 AM
Hello Sai,
Thankyou for your response.
After multiple try. Below script worked for me.
var gr = new GlideRecord("cmdb_ci_win_server");
gr.addQuery("sys_id", "mention sys id");
gr.query();
while(gr.next())
{
var co = gr.last_discovered;
var dt = new GlideDateTime();
var ageing= gs.dateDiff(co, dt, true);
var ageingDurInMin = Math.round(ageing/(60*60*24));
gs.print(ageing);
gs.print(ageingDurInMin);
if(ageingDurInMin < 7){
gr.operational_status= 1;
gr.install_status= 1;
gr.update();
}
}
Regards,
AB.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2021 06:24 AM
Hi Akansha
Before going Into Technical of Scripting my 2 cent questions is..
How and why Server is Retired when its still active and discoverable on its Old IP? Ask this question from Configuration Management Process team.
You should do the other way around . If a Server or CI is not discovered for lets say 4 weeks make it retired ,
Change the Status. This At least conforms in most of the cases - That given CI is not discovering meaning not on network.
Hope This helps.
Regards
RP