<?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 Send notification once at 30 days and 60 days in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/send-notification-once-at-30-days-and-60-days/m-p/2670607#M1035412</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am not sure I am putting this in the right forum but hope someone can assist.&lt;/P&gt;&lt;P&gt;I have created 2 notifications to send to ITIL users that have not logged in for over 30 days and 60 days.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Scenario 1:&lt;/P&gt;&lt;P&gt;ITIL user has not logged in for over 30 days&lt;/P&gt;&lt;OL class=""&gt;&lt;LI&gt;&lt;P&gt;Event: Last.login&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Notification: ITIL users not logged in for over 30 day&lt;/P&gt;&lt;OL class="lia-list-style-type-lower-alpha"&gt;&lt;LI&gt;Send When: Event is fired&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Scheduled job: Send ITIL not logged in for 30 days&lt;/P&gt;&lt;OL class="lia-list-style-type-lower-alpha"&gt;&lt;LI&gt;var gr = new GlideRecord('sys_user');&lt;BR /&gt;gr.addEncodedQuery('roles=ITIL^active=true^last_login&amp;lt;javascript&amp;amp;colon;gs.beginningOfLast30Days()^ORlast_loginISEMPTY');&lt;BR /&gt;gr.query();&lt;BR /&gt;while(gr.next()){&lt;BR /&gt;gs.eventQueue("Last.login", gr);&lt;BR /&gt;}&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;Job runs daily&lt;/LI&gt;&lt;LI&gt;Issue: Some users are getting the email notification every day and I only need it to send to them once&amp;nbsp;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Scenario 2:&lt;/P&gt;&lt;P&gt;ITIL Users not logged in for over 60 days&lt;/P&gt;&lt;P&gt;Created in Dev:&lt;/P&gt;&lt;OL class=""&gt;&lt;LI&gt;&lt;P&gt;Event: Last.login60&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Notification: ITIL users not logged in for over 60 day&lt;/P&gt;&lt;OL class="lia-list-style-type-lower-alpha"&gt;&lt;LI&gt;Send when: Event is fired&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Scheduled job: Send ITIL not logged in for 60 days&lt;/P&gt;&lt;OL class="lia-list-style-type-lower-alpha"&gt;&lt;LI&gt;var gr = new GlideRecord('sys_user');&lt;BR /&gt;gr.addEncodedQuery('roles=ITIL^active=true^last_login&amp;lt;javascript&amp;amp;colon;gs.beginningOfLast60Days()^ORlast_loginISEMPTY');&lt;BR /&gt;gr.query();&lt;BR /&gt;while(gr.next()){&lt;BR /&gt;gs.eventQueue("Last.login60", gr);&lt;BR /&gt;}&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;Job runs daily&lt;/LI&gt;&lt;LI&gt;Issue: Some users are getting the email notification every day and I only need it to send to them once&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I would appreciate any assistance on how to have the job run daily but only send the notification to the user once.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Gina&lt;/P&gt;</description>
    <pubDate>Wed, 13 Sep 2023 16:05:29 GMT</pubDate>
    <dc:creator>Bridgina Starr</dc:creator>
    <dc:date>2023-09-13T16:05:29Z</dc:date>
    <item>
      <title>Send notification once at 30 days and 60 days</title>
      <link>https://www.servicenow.com/community/developer-forum/send-notification-once-at-30-days-and-60-days/m-p/2670607#M1035412</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am not sure I am putting this in the right forum but hope someone can assist.&lt;/P&gt;&lt;P&gt;I have created 2 notifications to send to ITIL users that have not logged in for over 30 days and 60 days.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Scenario 1:&lt;/P&gt;&lt;P&gt;ITIL user has not logged in for over 30 days&lt;/P&gt;&lt;OL class=""&gt;&lt;LI&gt;&lt;P&gt;Event: Last.login&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Notification: ITIL users not logged in for over 30 day&lt;/P&gt;&lt;OL class="lia-list-style-type-lower-alpha"&gt;&lt;LI&gt;Send When: Event is fired&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Scheduled job: Send ITIL not logged in for 30 days&lt;/P&gt;&lt;OL class="lia-list-style-type-lower-alpha"&gt;&lt;LI&gt;var gr = new GlideRecord('sys_user');&lt;BR /&gt;gr.addEncodedQuery('roles=ITIL^active=true^last_login&amp;lt;javascript&amp;amp;colon;gs.beginningOfLast30Days()^ORlast_loginISEMPTY');&lt;BR /&gt;gr.query();&lt;BR /&gt;while(gr.next()){&lt;BR /&gt;gs.eventQueue("Last.login", gr);&lt;BR /&gt;}&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;Job runs daily&lt;/LI&gt;&lt;LI&gt;Issue: Some users are getting the email notification every day and I only need it to send to them once&amp;nbsp;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Scenario 2:&lt;/P&gt;&lt;P&gt;ITIL Users not logged in for over 60 days&lt;/P&gt;&lt;P&gt;Created in Dev:&lt;/P&gt;&lt;OL class=""&gt;&lt;LI&gt;&lt;P&gt;Event: Last.login60&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Notification: ITIL users not logged in for over 60 day&lt;/P&gt;&lt;OL class="lia-list-style-type-lower-alpha"&gt;&lt;LI&gt;Send when: Event is fired&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Scheduled job: Send ITIL not logged in for 60 days&lt;/P&gt;&lt;OL class="lia-list-style-type-lower-alpha"&gt;&lt;LI&gt;var gr = new GlideRecord('sys_user');&lt;BR /&gt;gr.addEncodedQuery('roles=ITIL^active=true^last_login&amp;lt;javascript&amp;amp;colon;gs.beginningOfLast60Days()^ORlast_loginISEMPTY');&lt;BR /&gt;gr.query();&lt;BR /&gt;while(gr.next()){&lt;BR /&gt;gs.eventQueue("Last.login60", gr);&lt;BR /&gt;}&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;Job runs daily&lt;/LI&gt;&lt;LI&gt;Issue: Some users are getting the email notification every day and I only need it to send to them once&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I would appreciate any assistance on how to have the job run daily but only send the notification to the user once.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Gina&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 16:05:29 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/send-notification-once-at-30-days-and-60-days/m-p/2670607#M1035412</guid>
      <dc:creator>Bridgina Starr</dc:creator>
      <dc:date>2023-09-13T16:05:29Z</dc:date>
    </item>
    <item>
      <title>Re: Send notification once at 30 days and 60 days</title>
      <link>https://www.servicenow.com/community/developer-forum/send-notification-once-at-30-days-and-60-days/m-p/2670789#M1035451</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/82739"&gt;@Bridgina Starr&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please try the below code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var gr = new GlideRecord('sys_user');&lt;BR /&gt;&lt;SPAN&gt;gr.&lt;/SPAN&gt;&lt;SPAN class=""&gt;addEncodedQuery&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;'roles=ITIL^active=true^last_login&amp;lt;javascript&amp;amp;colon;gs.daysAgoStart(30)'&lt;/SPAN&gt;&lt;SPAN&gt;); &lt;/SPAN&gt;&lt;BR /&gt;gr.query();&lt;BR /&gt;while(gr.next()){&lt;BR /&gt;gs.eventQueue("Last.login", gr);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Don't forget to mark my answer as Correct &amp;amp; Helpful, if applicable.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Krishna Sharma&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 18:34:42 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/send-notification-once-at-30-days-and-60-days/m-p/2670789#M1035451</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2023-09-13T18:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: Send notification once at 30 days and 60 days</title>
      <link>https://www.servicenow.com/community/developer-forum/send-notification-once-at-30-days-and-60-days/m-p/2670790#M1035452</link>
      <description>&lt;P&gt;Here are a couple different ideas that you could try:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Change your encoded query so that it only runs when the last_login is equal to the 30 or 60 days, rather than using "&amp;lt;". This could work if the job is running every day and if a last_login value exists. This wouldn't work for users that have already had their last_login time exceeding 60 days.&lt;/LI&gt;&lt;LI&gt;Add a hidden field to sys_user to keep track of whether or not that user has had a notification already. For example, you could have a date field that stores when they were sent their most recent last login notification. That way, your encoded query could check the last_login date as well as the previous last login notification timestamp to determine whether or not another notification should be sent.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I'm sure there are other solutions out there, but those were two fairly simple ideas that came to mind right off the bat. The system would need a way to know that the notification has already been sent, so as long as you could give it a way to record that, you should be able to accomplish your goal.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps point you in the right direction!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 18:34:47 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/send-notification-once-at-30-days-and-60-days/m-p/2670790#M1035452</guid>
      <dc:creator>Aylee Andersen</dc:creator>
      <dc:date>2023-09-13T18:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: Send notification once at 30 days and 60 days</title>
      <link>https://www.servicenow.com/community/developer-forum/send-notification-once-at-30-days-and-60-days/m-p/2670868#M1035474</link>
      <description>&lt;P&gt;A simple solution would be checking if 'email notification has already been sent for the user' before you trigger the event with the user gliderecord i.e&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Lato; font-size: 10.5pt; color: #1d1d1d;"&gt;&lt;SPAN&gt;var gr = new GlideRecord('sys_user');&lt;BR /&gt;gr.addEncodedQuery('roles=ITIL^active=true^last_login&amp;lt;javascript&amp;amp;colon;gs.beginningOfLast60Days()^ORlast_loginISEMPTY');&lt;BR /&gt;gr.query();&lt;BR /&gt;while(gr.next()){&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Lato; font-size: 10.5pt; color: #1d1d1d;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Lato; font-size: 10.5pt; color: #1d1d1d;"&gt;&lt;EM&gt;&lt;STRONG&gt;//check if email has already been sent for the same user lets say in last X days&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P style="margin: 0in;"&gt;&lt;STRONG&gt;var emailGR = new GlideRecord('sys_email');&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="margin: 0in;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in;"&gt;&lt;STRONG&gt;emailGR.addEncodedQuery(); //Query should be &lt;U&gt;created at or after X days&lt;/U&gt; AND &lt;U&gt;Subject LIKE &amp;lt;ITIL not logged in&amp;gt;&lt;/U&gt; AND &lt;U&gt;Recipients Contains gr.user.email_id&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="margin: 0in;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;" lang="en-US"&gt;&lt;STRONG&gt;emailGR.query();&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;" lang="en-US"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;" lang="en-US"&gt;&lt;STRONG&gt;//If any email is NOT found for this user in last X days trigger the event&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;" lang="en-US"&gt;&lt;STRONG&gt;If(!emailGR.next()){&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Lato; font-size: 10.5pt; color: #1d1d1d;"&gt;&lt;STRONG&gt;gs.eventQueue("Last.loginX", gr);&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;" lang="en-US"&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Lato; font-size: 10.5pt; color: #1d1d1d;"&gt;&lt;SPAN&gt;&lt;BR /&gt;}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Lato; font-size: 10.5pt; color: #1d1d1d;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Lato; font-size: 10.5pt; color: #1d1d1d;"&gt;&lt;SPAN&gt;Please mark the response as helpful if it resolves your issue&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 20:09:08 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/send-notification-once-at-30-days-and-60-days/m-p/2670868#M1035474</guid>
      <dc:creator>gurjot5</dc:creator>
      <dc:date>2023-09-13T20:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: Send notification once at 30 days and 60 days</title>
      <link>https://www.servicenow.com/community/developer-forum/send-notification-once-at-30-days-and-60-days/m-p/2671814#M1035814</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/82739"&gt;@Bridgina Starr&lt;/a&gt;&amp;nbsp;if this solved your issue please mark the response as helpful and please accept the solution so that others can benefit from the content , thank you &lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Sep 2023 13:21:48 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/send-notification-once-at-30-days-and-60-days/m-p/2671814#M1035814</guid>
      <dc:creator>gurjot5</dc:creator>
      <dc:date>2023-09-14T13:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: Send notification once at 30 days and 60 days</title>
      <link>https://www.servicenow.com/community/developer-forum/send-notification-once-at-30-days-and-60-days/m-p/2676105#M1037372</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I thought about trying your suggestion, "Change your encoded query so that it only runs when the last_login is equal to the 30 or 60 days, rather than using "&amp;lt;". This could work if the job is running every day and if a last_login value exists. This wouldn't work for users that have already had their last_login time exceeding 60 days.".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I am hesitant as I still feel like this will send the same user an email everyday if they don't login. I only want to send it to them once.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do appreciate your input. I am trying something else and if that does not work, I will be trying your second suggestion of adding a "hidden field".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Gina&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2023 17:44:38 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/send-notification-once-at-30-days-and-60-days/m-p/2676105#M1037372</guid>
      <dc:creator>Bridgina Starr</dc:creator>
      <dc:date>2023-09-19T17:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: Send notification once at 30 days and 60 days</title>
      <link>https://www.servicenow.com/community/developer-forum/send-notification-once-at-30-days-and-60-days/m-p/2676110#M1037373</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I appreciate your input. I have tried this, and it is not working. I think it may have something to do with "&lt;STRONG&gt;gr.user.email_id"&lt;/STRONG&gt; but don't know for sure. I am working with another developer,&amp;nbsp;but we have been quite busy and have not gotten a chance to back to this. I also just noticed that you have "contains" in your script but ours has like so I am going to go back and try that and see. I will keep you updated, and I am sorry for the delay.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Gina&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2023 17:50:31 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/send-notification-once-at-30-days-and-60-days/m-p/2676110#M1037373</guid>
      <dc:creator>Bridgina Starr</dc:creator>
      <dc:date>2023-09-19T17:50:31Z</dc:date>
    </item>
  </channel>
</rss>

