<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Custom Discovery Schedule with a Condition Script in ITOM forum</title>
    <link>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034464#M98264</link>
    <description>&lt;P&gt;The "Run" choices we have when setting up a Discovery Schedule are:&lt;/P&gt;
&lt;UL&gt;&lt;LI&gt;Daily&lt;/LI&gt;&lt;LI&gt;Weekly&lt;/LI&gt;&lt;LI&gt;Monthly&lt;/LI&gt;&lt;LI&gt;Periodically&lt;/LI&gt;&lt;LI&gt;Once&lt;/LI&gt;&lt;LI&gt;On Demand&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We would have to create multiple schedules in order to run a Discovery every weekday or just weekends. &amp;nbsp; Or do we?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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. &amp;nbsp; By adding those fields to the Discovery Schedule form, we can now use a script to decide when it should run. &amp;nbsp; 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:&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;(function() {
  //run on weekends only
  var day = new Date().getDay();
  return (day == 0 || day == 6);

})();

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Skip Sundays:&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;(function() {
   //skip Sundays
   var day = new Date().getDay();
   return (day != 6);

})();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This script for Monday to Friday:&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;(function() {
  //run Monday to Friday
  var day = new Date().getDay();
  return (day != 0 &amp;amp;&amp;amp; day != 6);

})();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This one for Monday, Wednesday and Fridays:&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;(function() {
  //run on Monday, Wednesday and Fridays
  var day = new Date().getDay();
  return (day == 1 || day == 3 || day == 5);

})();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;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.&lt;/P&gt;</description>
    <pubDate>Fri, 28 Mar 2014 14:11:57 GMT</pubDate>
    <dc:creator>Jim Coyne</dc:creator>
    <dc:date>2014-03-28T14:11:57Z</dc:date>
    <item>
      <title>Custom Discovery Schedule with a Condition Script</title>
      <link>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034464#M98264</link>
      <description>&lt;P&gt;The "Run" choices we have when setting up a Discovery Schedule are:&lt;/P&gt;
&lt;UL&gt;&lt;LI&gt;Daily&lt;/LI&gt;&lt;LI&gt;Weekly&lt;/LI&gt;&lt;LI&gt;Monthly&lt;/LI&gt;&lt;LI&gt;Periodically&lt;/LI&gt;&lt;LI&gt;Once&lt;/LI&gt;&lt;LI&gt;On Demand&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We would have to create multiple schedules in order to run a Discovery every weekday or just weekends. &amp;nbsp; Or do we?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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. &amp;nbsp; By adding those fields to the Discovery Schedule form, we can now use a script to decide when it should run. &amp;nbsp; 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:&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;(function() {
  //run on weekends only
  var day = new Date().getDay();
  return (day == 0 || day == 6);

})();

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Skip Sundays:&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;(function() {
   //skip Sundays
   var day = new Date().getDay();
   return (day != 6);

})();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This script for Monday to Friday:&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;(function() {
  //run Monday to Friday
  var day = new Date().getDay();
  return (day != 0 &amp;amp;&amp;amp; day != 6);

})();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This one for Monday, Wednesday and Fridays:&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;(function() {
  //run on Monday, Wednesday and Fridays
  var day = new Date().getDay();
  return (day == 1 || day == 3 || day == 5);

})();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Mar 2014 14:11:57 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034464#M98264</guid>
      <dc:creator>Jim Coyne</dc:creator>
      <dc:date>2014-03-28T14:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Discovery Schedule with a Condition Script</title>
      <link>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034465#M98265</link>
      <description>&lt;P&gt;Jim,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I promise to make every effort to make scheduling easier in the future. Nice workaround. &lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 31 Mar 2014 22:13:32 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034465#M98265</guid>
      <dc:creator>aleck_lin</dc:creator>
      <dc:date>2014-03-31T22:13:32Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Discovery Schedule with a Condition Script</title>
      <link>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034466#M98266</link>
      <description>&lt;P&gt;It would be nice to have the following additional "Run" options for all Scheduled Jobs:&lt;/P&gt;&lt;BR /&gt;&lt;UL&gt;&lt;LI&gt;Weekdays&lt;/LI&gt;&lt;LI&gt;Weekends&lt;/LI&gt;&lt;LI&gt;Last day of the month&lt;/LI&gt;&lt;LI&gt;Start of Calendar Quarter&lt;/LI&gt;&lt;LI&gt;End of Calendar Quarter&lt;/LI&gt;&lt;LI&gt;In this Schedule&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;The "In this Schedule" option would then allow us to select a custom Schedule record which would allow us to configure really custom run times.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 31 Mar 2014 22:27:03 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034466#M98266</guid>
      <dc:creator>Jim Coyne</dc:creator>
      <dc:date>2014-03-31T22:27:03Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Discovery Schedule with a Condition Script</title>
      <link>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034467#M98267</link>
      <description>&lt;P&gt;Excellent. I was looking for something just like this!&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Jul 2014 20:02:34 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034467#M98267</guid>
      <dc:creator>KCallaghan</dc:creator>
      <dc:date>2014-07-08T20:02:34Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Discovery Schedule with a Condition Script</title>
      <link>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034468#M98268</link>
      <description>&lt;P&gt;Could you assist with script for quarterly report?&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Jun 2016 20:12:10 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034468#M98268</guid>
      <dc:creator>Malaya</dc:creator>
      <dc:date>2016-06-07T20:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Discovery Schedule with a Condition Script</title>
      <link>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034469#M98269</link>
      <description>&lt;P&gt;Sure. &amp;nbsp; Set the "Run" field to "Monthly" and select the day you want it to run on (e.g. 1 for the first day of the month), check the "Conditional" checkbox and use the following script in the "Condition" field:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="_jivemacro_uid_14653946217183935 jive_macro_code jive_text_macro" data-renderedposition="71_8_1192_82" jivemacro_uid="_14653946217183935"&gt;&lt;P&gt;(function(){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; //run after each quarterly end date&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; var month = new GlideDateTime().getMonthLocalTime();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; return (month == 1 || month == 4 || month == 7 || month == 10);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5;"&gt;})();&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5;"&gt;That will then just run once a month and assumes calendar quarters. &amp;nbsp; The report would then run on the first day of January, April, July and October, the day after the quarterly end dates. &amp;nbsp; You might have to tweak for your own needs.&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 08 Jun 2016 14:02:09 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034469#M98269</guid>
      <dc:creator>Jim Coyne</dc:creator>
      <dc:date>2016-06-08T14:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Discovery Schedule with a Condition Script</title>
      <link>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034470#M98270</link>
      <description>&lt;P&gt;Thanks Jim.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 08 Jun 2016 14:35:39 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034470#M98270</guid>
      <dc:creator>Malaya</dc:creator>
      <dc:date>2016-06-08T14:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Discovery Schedule with a Condition Script</title>
      <link>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034471#M98271</link>
      <description>&lt;P&gt;You are welcome.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 08 Jun 2016 14:36:55 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034471#M98271</guid>
      <dc:creator>Jim Coyne</dc:creator>
      <dc:date>2016-06-08T14:36:55Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Discovery Schedule with a Condition Script</title>
      <link>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034472#M98272</link>
      <description>&lt;P&gt;Jim,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I want to create a schedule to run on the first Sunday of every quarter. &amp;nbsp; Any advice is greatly appreciated.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 13 Mar 2017 16:38:35 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034472#M98272</guid>
      <dc:creator>markgood</dc:creator>
      <dc:date>2017-03-13T16:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Discovery Schedule with a Condition Script</title>
      <link>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034473#M98273</link>
      <description>&lt;P&gt;This should do the trick - s&lt;SPAN style="color: #666666; font-family: arial, sans-serif;"&gt;et the "Run" field to "Weekly" and "Day" to "Sunday", check the "Conditional" checkbox and use the following script in the "Condition" field:&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14895210050008592" data-renderedposition="50_8_1192_144" jivemacro_uid="_14895210050008592"&gt;&lt;P&gt;(function(){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; //run on the first Sunday of every quarter&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; var gdt = new GlideDateTime();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; var month = gdt.getMonthLocalTime();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; var day = gdt.getDayOfMonthLocalTime();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; //returns true if the month is January, April, July or October AND the day is within the first week&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; return (month == 1 || month == 4 || month == 7 || month == 10) &amp;amp;&amp;amp; (day &amp;lt;= 7);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;})();&lt;/P&gt;&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Mar 2017 19:53:05 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034473#M98273</guid>
      <dc:creator>Jim Coyne</dc:creator>
      <dc:date>2017-03-14T19:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Discovery Schedule with a Condition Script</title>
      <link>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034474#M98274</link>
      <description>&lt;P&gt;Jim,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Thank you so much. &lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Mar 2017 20:34:03 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034474#M98274</guid>
      <dc:creator>markgood</dc:creator>
      <dc:date>2017-03-14T20:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Discovery Schedule with a Condition Script</title>
      <link>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034475#M98275</link>
      <description>&lt;P&gt;You are welcome. &amp;nbsp; Do you mind marking the post as being "Helpful"? &amp;nbsp; That helps members see responses that are of value. &amp;nbsp; Thanks&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/101953i73A2B984C10F206B/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Mar 2017 20:54:27 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034475#M98275</guid>
      <dc:creator>Jim Coyne</dc:creator>
      <dc:date>2017-03-14T20:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Discovery Schedule with a Condition Script</title>
      <link>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034476#M98276</link>
      <description>&lt;P&gt;I second Jim's list of options and would like to add two more:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;First Day of Week&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;First Day of Month.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;That way I can easily run a report on the previous time period.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Mar 2017 21:19:50 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034476#M98276</guid>
      <dc:creator>HugoFirst</dc:creator>
      <dc:date>2017-03-14T21:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Discovery Schedule with a Condition Script</title>
      <link>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034477#M98277</link>
      <description>&lt;P&gt;Not sure when they were added, but the following additional options are available in Fuji, Geneva, Helsinki and Istanbul now:&lt;/P&gt;&lt;BR /&gt;&lt;UL&gt;&lt;LI&gt;Weekdays&lt;/LI&gt;&lt;LI&gt;Weekends&lt;/LI&gt;&lt;LI&gt;Month Last Day&lt;/LI&gt;&lt;LI&gt;Calendar Quarter End&lt;/LI&gt;&lt;LI&gt;After Discovery&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Nice to see 4 of the 6 suggestions were added, but I'm a little confused why they were only added for Discovery Schedules and not all Scheduled Jobs? &amp;nbsp; Obviously "After Discovery" make sense just for Discovery, but the other options would have been useful for all jobs.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;A title="aleck.lin" __default_attr="2222" __jive_macro_name="user" class="jive-link-profile-small jive_macro jive_macro_user" data-id="2222" data-objecttype="3" data-orig-content="aleck.lin" data-renderedposition="236.78125_8_70_16" data-type="person" href="https://www.servicenow.com/community?id=community_user_profile&amp;amp;user=0183d2e9db1c1fc09c9ffb651f9619fc"&gt;aleck.lin&lt;/A&gt; do you know the reason they were limited to Discovery only?&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Mar 2017 22:35:26 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034477#M98277</guid>
      <dc:creator>Jim Coyne</dc:creator>
      <dc:date>2017-03-14T22:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Discovery Schedule with a Condition Script</title>
      <link>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034478#M98278</link>
      <description>&lt;P&gt;Yah, that's a fair question. To truly solve the scheduling problem, there really needs to be another layer of scheduling capabilities built on top of sys_trigger and sysauto (by the way, I'm no longer in dev and this is my personal opinion). We solved the problem for Discovery because we introduced our own layer of complexity to work with those scheduled jobs. At the end of the day, I agree that this would be better solved on the platform side, but short of that, we at least made it possible for Discovery. We need folks like you to enter in enhancement requests to the platform team to make this possible. &lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Mar 2017 23:43:52 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034478#M98278</guid>
      <dc:creator>aleck_lin</dc:creator>
      <dc:date>2017-03-14T23:43:52Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Discovery Schedule with a Condition Script</title>
      <link>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034479#M98279</link>
      <description>&lt;P&gt;Absolutely. &amp;nbsp; Sorry for the oversight on my part.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 15 Mar 2017 12:51:55 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034479#M98279</guid>
      <dc:creator>markgood</dc:creator>
      <dc:date>2017-03-15T12:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Discovery Schedule with a Condition Script</title>
      <link>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034480#M98280</link>
      <description>&lt;P&gt;No problem. &amp;nbsp; Thanks!&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 15 Mar 2017 14:54:48 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034480#M98280</guid>
      <dc:creator>Jim Coyne</dc:creator>
      <dc:date>2017-03-15T14:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Discovery Schedule with a Condition Script</title>
      <link>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034481#M98281</link>
      <description>&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Oct 2018 13:03:12 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034481#M98281</guid>
      <dc:creator>Jim Coyne</dc:creator>
      <dc:date>2018-10-20T13:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Discovery Schedule with a Condition Script</title>
      <link>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034482#M98282</link>
      <description>&lt;P&gt;Jim,&amp;nbsp; I am trying to setup a scheduled job to create a requested item on the 2nd and 4th Tuesday.&amp;nbsp; Can this be done in one scheduled job or would I have to create 2 separate scheduled jobs and use the conditional formatting?&amp;nbsp; Can you provide some help on the conditional script I would need to use to accomplish this?&amp;nbsp; Any help is greatly appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Russell&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2019 18:00:15 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034482#M98282</guid>
      <dc:creator>Russell Park</dc:creator>
      <dc:date>2019-01-04T18:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Discovery Schedule with a Condition Script</title>
      <link>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034483#M98283</link>
      <description>&lt;P&gt;Try this condition script:&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;answer = (function(){
    //initialize
    var result = false;
    var tuesdays = [];
    var today = new Date().getDate();
    var day = new Date();
    var month = day.getMonth();

    //start on the first day of the month...
    day.setDate(1);

    //...and find the first Tuesday in the month
    while (day.getDay() !== 2) {
        day.setDate(day.getDate() + 1);
    }

    //get all the other Tuesdays in the month
    while (day.getMonth() === month) {
        tuesdays.push(day.getDate());
        day.setDate(day.getDate() + 7);
    }
 
    //is today the 2nd or 4th Tuesday? (array index starts at 0)
    if (today == tuesdays[1] || today == tuesdays[3]) {
        result = true;
    }
    return result;
})();&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Jan 2019 17:09:47 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itom-forum/custom-discovery-schedule-with-a-condition-script/m-p/1034483#M98283</guid>
      <dc:creator>Jim Coyne</dc:creator>
      <dc:date>2019-01-07T17:09:47Z</dc:date>
    </item>
  </channel>
</rss>

