- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2024 08:54 PM
Good evening,
Just a quick question. I need to send an email reminder on the 5th day for suppliers who have not taken their survey.
Could someone tell me if the below code looks okay?
Best regards,
charri04
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2024 10:54 PM
Why a scheduled job?
Just create a flow on survey creation. Add the flow logic 'wait for a duration of time' and set that to 5 days. do a check to see if the survey is still open and if so, use the 'send notification' action. No need for scripting at all.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2024 11:48 PM
Hi @charri04 ,
Please try below code this will works for you
// var query = 'sys_created_onRELATIVELT@dayofweek@ago@5';
var gr = new GlideRecord('asmt_assessment_instance');
gr.addEncodedQuery('metric_type.nameLIKESupplier Case Satisfaction Survey^stateINready,wip^userISNOTEMPTY');
gr.query();
while (gr.next()) {
var createddate = gr.sys_created_on;
var createdDateGDT = new GlideDateTime(createddate);
var currentDate = new GlideDateTime();
var dur = GlideDateTime.subtract(createdDateGDT, currentDate); // Difference between gdt1 and gdt2
var daysCount = dur.getDayPart()
gs.info(daysCount);
if (daysCount == 5) {
gs.print("1 = " + createdDateGDT + " 2 = " + currentDate);
gs.eventQueue('sn_supplier.case.reminder_5days', gr, gr.user, '');
}
}
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2024 10:54 PM
Why a scheduled job?
Just create a flow on survey creation. Add the flow logic 'wait for a duration of time' and set that to 5 days. do a check to see if the survey is still open and if so, use the 'send notification' action. No need for scripting at all.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2024 12:21 PM
Thanks @Mark Manders for responding!
It took a bit of trial and error but decided to go with the flow instead of scripting.
Best regards,
Corey

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2024 11:48 PM
Hi @charri04 ,
Please try below code this will works for you
// var query = 'sys_created_onRELATIVELT@dayofweek@ago@5';
var gr = new GlideRecord('asmt_assessment_instance');
gr.addEncodedQuery('metric_type.nameLIKESupplier Case Satisfaction Survey^stateINready,wip^userISNOTEMPTY');
gr.query();
while (gr.next()) {
var createddate = gr.sys_created_on;
var createdDateGDT = new GlideDateTime(createddate);
var currentDate = new GlideDateTime();
var dur = GlideDateTime.subtract(createdDateGDT, currentDate); // Difference between gdt1 and gdt2
var daysCount = dur.getDayPart()
gs.info(daysCount);
if (daysCount == 5) {
gs.print("1 = " + createdDateGDT + " 2 = " + currentDate);
gs.eventQueue('sn_supplier.case.reminder_5days', gr, gr.user, '');
}
}
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2024 12:23 PM
Hi @Community Alums !
Thanks for responding and helping me out with the code. I did try the code and it worked! I decided to go with flow designer to make it easier on the client that I'm currently working with.
Best regards,
Corey