<?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 Scheduled Job in ServiceNow Otto for Creator forum</title>
    <link>https://www.servicenow.com/community/servicenow-otto-for-creator/scheduled-job/m-p/3102497#M158</link>
    <description>&lt;P&gt;I am creating a scheduled job to to send out daily emails to the assigned user for incidents not active in 3 days excluding weekends. I have the condition for the exclusion below:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; result = &lt;/SPAN&gt;&lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; gdt = &lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;GlideDateTime&lt;/SPAN&gt;&lt;SPAN&gt;();&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; day = gdt.getDayOfWeekLocalTime(); &lt;/SPAN&gt;&lt;SPAN&gt;//The day of week value from 1 to 7. Monday equals 1, Sunday equals 7.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(day==&lt;/SPAN&gt;&lt;SPAN&gt;6&lt;/SPAN&gt;&lt;SPAN&gt;||day==&lt;/SPAN&gt;&lt;SPAN&gt;7&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;result =&lt;/SPAN&gt;&lt;SPAN&gt;false&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;result ;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I am stuck on the actual script that I need to write below the condition.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 12 Nov 2024 14:43:02 GMT</pubDate>
    <dc:creator>MoeG82</dc:creator>
    <dc:date>2024-11-12T14:43:02Z</dc:date>
    <item>
      <title>Scheduled Job</title>
      <link>https://www.servicenow.com/community/servicenow-otto-for-creator/scheduled-job/m-p/3102497#M158</link>
      <description>&lt;P&gt;I am creating a scheduled job to to send out daily emails to the assigned user for incidents not active in 3 days excluding weekends. I have the condition for the exclusion below:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; result = &lt;/SPAN&gt;&lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; gdt = &lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;GlideDateTime&lt;/SPAN&gt;&lt;SPAN&gt;();&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; day = gdt.getDayOfWeekLocalTime(); &lt;/SPAN&gt;&lt;SPAN&gt;//The day of week value from 1 to 7. Monday equals 1, Sunday equals 7.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(day==&lt;/SPAN&gt;&lt;SPAN&gt;6&lt;/SPAN&gt;&lt;SPAN&gt;||day==&lt;/SPAN&gt;&lt;SPAN&gt;7&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;result =&lt;/SPAN&gt;&lt;SPAN&gt;false&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;result ;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I am stuck on the actual script that I need to write below the condition.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 12 Nov 2024 14:43:02 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-otto-for-creator/scheduled-job/m-p/3102497#M158</guid>
      <dc:creator>MoeG82</dc:creator>
      <dc:date>2024-11-12T14:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: Scheduled Job</title>
      <link>https://www.servicenow.com/community/servicenow-otto-for-creator/scheduled-job/m-p/3102558#M159</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/592249"&gt;@MoeG82&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;are you saying you want to check if incident is assigned and still not updated for more than 3 business days?&lt;/P&gt;
&lt;P&gt;what's your business requirement here? I am little confused&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2024 15:12:57 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-otto-for-creator/scheduled-job/m-p/3102558#M159</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2024-11-12T15:12:57Z</dc:date>
    </item>
    <item>
      <title>Re: Scheduled Job</title>
      <link>https://www.servicenow.com/community/servicenow-otto-for-creator/scheduled-job/m-p/3102578#M160</link>
      <description>&lt;P&gt;Yes, I need to check for incidents assigned but have not been updated in 3 days.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2024 15:21:55 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-otto-for-creator/scheduled-job/m-p/3102578#M160</guid>
      <dc:creator>MoeG82</dc:creator>
      <dc:date>2024-11-12T15:21:55Z</dc:date>
    </item>
    <item>
      <title>Re: Scheduled Job</title>
      <link>https://www.servicenow.com/community/servicenow-otto-for-creator/scheduled-job/m-p/3102589#M161</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/592249"&gt;@MoeG82&lt;/a&gt;&amp;nbsp;To build your scheduled job for sending daily email notifications to assigned users of incidents that have not been updated in 3 business days (excluding weekends), you can follow the below sample script:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; var scheduleId = '08a760a4a9fe198100ff1d8b29b9a71c'; // Replace with your actual schedule sys_id from cmn_scheduke other explicitly you will have to define date logic&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; var glideSchedule = new GlideSchedule(scheduleId);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; // Get the current date and calculate the date 3 business days ago&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; var now = new GlideDateTime();&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; var threeBusinessDaysAgo = glideSchedule.subtract(now, 3, 'business');&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; // Query for inactive incidents not updated in the last 3 business days&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; var gr = new GlideRecord('incident');&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; gr.addActiveQuery(false); // Only inactive incidents&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; gr.addQuery('sys_updated_on', '&amp;lt;=', threeBusinessDaysAgo);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; gr.addNotNullQuery('assigned_to'); // Ensure it has an assigned user&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; gr.query();&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; // Trigger the existing notification event for each matching incident&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; while (gr.next()) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Trigger the event for the existing notification&lt;SPAN&gt;&amp;nbsp; gs.eventQueue('incident.reminder.inactive', gr, gr.assigned_to, gr.number);// if not then create a new notification and you can change param1 and 2 as per your requirement&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;gs.info("Notification event triggered for Incident: " + gr.number + " assigned to " + gr.assigned_to.getDisplayValue());&lt;/P&gt;&lt;P&gt;Please test on lower instance first.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2024 15:36:48 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-otto-for-creator/scheduled-job/m-p/3102589#M161</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2024-11-12T15:36:48Z</dc:date>
    </item>
  </channel>
</rss>

