You are on page 1of 5

5/7/2020 Reminder Notification Issue - Developer Community - ServiceNow Community

 Question

Reminder Noti cation Issue


by johny
J
created about a year ago (edited about a year ago ) in Developer Community

The 3  approval remainders should sent to the approver each week a part.
I have used the scheduled job to achieve this.
ISSUE:
Many of the same records(Reminders) were present in all the three reminders.

var scApp = new GlideRecord('sysapproval_approver');


scApp.addEncodedQuery('state=requested^sysapproval.sys_class_name=sc_req_item');
scApp.query();
while (scApp.next()){
if (scApp.sys_created_on <= gs.daysAgo(7)){
gs.eventQueue('sc_reminder1',scApp,scApp.approver);
}

if (scApp.sys_created_on <= gs.daysAgo(14)){


gs.eventQueue('sc_reminder2',scApp,scApp.approver);
}

if (scApp.sys_created_on <= gs.daysAgo(21)){


gs.eventQueue('sc_reminder3',scApp,scApp.approver);
}
}

Topics: Scripting and Coding

 Upvotes (0) 187 Views

 Accepted Solution See this answer in context

AirSquire Forum Level 1 • about a year ago


A
Hi Johny,
Apply the below condition, (just adding, else if may also work correctly here)

https://community.servicenow.com/community?id=community_question&sys_id=295d7f26db38f7885ed4a851ca961982 1/5
5/7/2020 Reminder Notification Issue - Developer Community - ServiceNow Community

var scApp = new GlideRecord('sysapproval_approver');


scApp.addEncodedQuery('state=requested^sysapproval.sys_class_name=sc_req_it
scApp.query();
while (scApp.next()){
if (scApp.sys_created_on <= gs.daysAgo(7) && scApp.sys_created_on > gs
gs.eventQueue('sc_reminder1',scApp,scApp.approver);
}

if (scApp.sys_created_on <= gs.daysAgo(14) && scApp.sys_created_on > gs


gs.eventQueue('sc_reminder2',scApp,scApp.approver);
}

if (scApp.sys_created_on <= gs.daysAgo(21)){


gs.eventQueue('sc_reminder3',scApp,scApp.approver);
}
}

Regards
Air

 Helpful (0)  Replies (1)

7 Replies ( Latest reply about a year ago by johny ) Hide All Replies

David Dubuis Forum Level 4 • about a


year ago

You'll need to construct the conditions so you get approvals raised between date A and date B
eg:

if (scApp.sys_created_on <= gs.daysAgo(7)){


gs.eventQueue('sc_reminder1',scApp,scApp.approver);
}

if (scApp.sys_created_on <= gs.daysAgo(14) && scApp.sys_created_on > gs.days


gs.eventQueue('sc_reminder2',scApp,scApp.approver);
}

if (scApp.sys_created_on <= gs.daysAgo(21) && scApp.sys_created_on > gs.days


gs.eventQueue('sc_reminder3',scApp,scApp.approver);
}

 Helpful (0)  Hide Replies

johny  David Dubuis • about a year


J
ago Author
https://community.servicenow.com/community?id=community_question&sys_id=295d7f26db38f7885ed4a851ca961982 2/5
5/7/2020 Reminder Notification Issue - Developer Community - ServiceNow Community

Hi David,
For the above condition even there are records it is not showing any.
 

 Helpful (0)

AirSquire Forum Level 1 • about a


A
year ago 

Hi Johny,
Apply the below condition, (just adding, else if may also work correctly here)

var scApp = new GlideRecord('sysapproval_approver');


scApp.addEncodedQuery('state=requested^sysapproval.sys_class_name=sc_req_item');
scApp.query();
while (scApp.next()){
if (scApp.sys_created_on <= gs.daysAgo(7) && scApp.sys_created_on > gs.daysA
gs.eventQueue('sc_reminder1',scApp,scApp.approver);
}

if (scApp.sys_created_on <= gs.daysAgo(14) && scApp.sys_created_on > gs.days


gs.eventQueue('sc_reminder2',scApp,scApp.approver);
}

if (scApp.sys_created_on <= gs.daysAgo(21)){


gs.eventQueue('sc_reminder3',scApp,scApp.approver);
}
}

Regards
Air

 Helpful (0)  Hide Replies

johny  AirSquire • about a year ago


J
Author

Thank you Air.

 Helpful (0)

AirSquire Forum Level 1  johny


A
• about a year ago

I am glad it helped.
Regards
Air

https://community.servicenow.com/community?id=community_question&sys_id=295d7f26db38f7885ed4a851ca961982 3/5
5/7/2020 Reminder Notification Issue - Developer Community - ServiceNow Community

 Helpful (0)

johny • about a year ago Author


J
Thank you David and Air.
It seems to be not working either.
One more issue is I'm scheduling the job to Run it daily. If it is so reminder noti cations will
trigger to users daily.
Any idea how can we x this.
Requirement is there will be 3 approval reminders each a week apart
Reminder1
Reminder2
Reminder3

 Helpful (0)  Hide Replies

David Dubuis Forum Level 4 


johny
• about a year ago

You know, your best bet might be to set up some SLA's on the sysapproval_approver table
and set them to breach at 7, 14 and 21 days. You could go ahead and build all your own
scheduled jobs to run and to all the right checks but there's already a series of scheduled
jobs set up to run for SLA's so you might as well leverage them instead.
 

 Helpful (0)

https://community.servicenow.com/community?id=community_question&sys_id=295d7f26db38f7885ed4a851ca961982 4/5
5/7/2020 Reminder Notification Issue - Developer Community - ServiceNow Community

Contact Us    

Help
Terms of Use
Privacy Policy
Cookie Preferences
Trademark and Branding
ServiceNow Support

© 2020 ServiceNow. All rights reserved.

https://community.servicenow.com/community?id=community_question&sys_id=295d7f26db38f7885ed4a851ca961982 5/5

You might also like