How to set a discovery schedule to run 2 times a week

John Vo1
Tera Guru

Is it possible to set the discovery schedule to run on a Monday and then again on a Wednesday?

Thanks,

John

1 ACCEPTED SOLUTION

darius_koohmare
ServiceNow Employee
ServiceNow Employee

You can have the script run daily at the time you want it to run.


Then, set the conditional checkbox field to true and in the conditions section define:



  1. (function() {  
  2.   //run on Monday, Wednesday and Fridays  
  3.   var day = new Date().getDay();  
  4.   return (day == 1 || day == 3);  
  5. })();  


This will run the discovery every day, but will only actually execute successfully if it is monday or Wednesday.


View solution in original post

10 REPLIES 10

darius_koohmare
ServiceNow Employee
ServiceNow Employee

You can have the script run daily at the time you want it to run.


Then, set the conditional checkbox field to true and in the conditions section define:



  1. (function() {  
  2.   //run on Monday, Wednesday and Fridays  
  3.   var day = new Date().getDay();  
  4.   return (day == 1 || day == 3);  
  5. })();  


This will run the discovery every day, but will only actually execute successfully if it is monday or Wednesday.


Would this be a client script in the discovery schedule or business rule?


Not a client script or business rule.


Add the 'Conditional Checkbox' and 'Conditions' fields to the discovery schedule list or form view to set them.


Screen Shot 2017-01-04 at 4.14.08 PM.png


If this doesn't work there's always the option of doing two Weekly schedules.