- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2014 07:11 AM
The "Run" choices we have when setting up a Discovery Schedule are:
- Daily
- Weekly
- Monthly
- Periodically
- Once
- On Demand
We would have to create multiple schedules in order to run a Discovery every weekday or just weekends. Or do we?
It may not be obvious, but because the Discovery Schedule table is a subclass of the Scheduled Job table, we have access to the Conditional checkbox and Condition script fields. By adding those fields to the Discovery Schedule form, we can now use a script to decide when it should run. So for example, set the "Run" field to "Daily", check the "Conditional" field and add the following script to the "Condition" field to run a Discovery on weekends only:
(function() {
//run on weekends only
var day = new Date().getDay();
return (day == 0 || day == 6);
})();
Skip Sundays:
(function() {
//skip Sundays
var day = new Date().getDay();
return (day != 6);
})();
This script for Monday to Friday:
(function() {
//run Monday to Friday
var day = new Date().getDay();
return (day != 0 && day != 6);
})();
This one for Monday, Wednesday and Fridays:
(function() {
//run on Monday, Wednesday and Fridays
var day = new Date().getDay();
return (day == 1 || day == 3 || day == 5);
})();
So what happens is the Discovery Schedule will in fact "run" every day at the specified time, but if the condition fails, the job ends without actually kicking off a Discovery.
Solved! Go to Solution.
- Labels:
-
Discovery
-
Service Mapping
- 5,460 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2018 06:03 AM
Just setting this answer as correct as the actual thread was not meant as a question and it cannot be changed because it came from the original Community site.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2017 05:51 AM
Absolutely. Sorry for the oversight on my part.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2017 07:54 AM
No problem. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2018 06:03 AM
Just setting this answer as correct as the actual thread was not meant as a question and it cannot be changed because it came from the original Community site.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2020 07:35 AM
Jim,
Is it possible to put a time in the script to run it at 8am, 12pm and 3pm? Here is my script.
(function() {
//run on Monday, Wednesday and Friday
var day = new Date().getDay();
return (day == 1 || day == 3 || day == 5);
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2019 10:00 AM
Jim, I am trying to setup a scheduled job to create a requested item on the 2nd and 4th Tuesday. Can this be done in one scheduled job or would I have to create 2 separate scheduled jobs and use the conditional formatting? Can you provide some help on the conditional script I would need to use to accomplish this? Any help is greatly appreciated.
Russell