Business Rule is not working properly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2022 12:18 AM
Hi all,
I have a requirement to send survey reminder after 12 hours of creation. So i created an onAfter() BR but that is not working as intended.
Any help would be greatly appreciable.
Thanks in Advance
When : After, Insert
Table : Assessment Instance
logic :
(function executeRule(current, previous /*null when async*/) {
var sys_id = current.getValue('sys_id');
var gdt = new GlideDateTime('current.sys_created_on.getDisplayValue()');
// gdt.addSeconds(43200);
gdt.addSeconds(300); // for testing
var s = new GlideRecord('sysauto_script');
s.initialize();
s.name = "Survey Reminder for : "+current.number;
s.active = true;
s.run_type = 'once';
s.run_start = gdt.getValue();
var script = "sendReminder();/n function sendReminder() {/n var gr = new GlideRecord('asmt_assessment_instance');/n gr.get('"+sys_id+"');/n if (gr.metric_type == '*****sys_id*****' && gr.state == 'ready') {/n gs.eventQueue('assessment.inc.reminder', gr, gr.user);/n } else if (gr.metric_type == '*****sys_id*****' && gr.state == 'ready') {/n gs.eventQueue('assessment.req.reminder', gr, gr.user);/n }/n }";
s.script = script;
s.insert();
})(current, previous);
- Labels:
-
Script Debugger
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2022 12:34 AM
Please tryi with gs.eventQueueScheduled().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2022 12:39 AM
Thanks Saket for your reply.
Actually the issue is Scheduled job is not all getting created.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2022 12:38 AM
Hi,
why not use flow designer for this with no script?
Your flow will trigger as soon as record inserted and then wait for 12 hours and then send email
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2022 12:41 AM
hi Ankur,
Thanks for your reply.... Actually i am not familiar with Flow Designer.. So i tried creating a BR... Let me give a try.
Any help with the script would be greatly appreciable