Triggering an event from a Fix Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2019 01:17 PM
I am trying to trigger an event from a fix script which I will eventually convert into a scheduled job. I want to basically trigger the event when there are any new records created on a custom table that day. I have the below script which I can see has fired the event that calls the notification in the logs but I am wondering about how to do a couple of things.
Fix Script
var queryString = "sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()";
var grq = new GlideRecord('u_custom_table');
grq.addEncodedQuery(queryString);
grq.query();
gs.log('CUSTOM TABLE NAME: TABLE CHECK: ROW COUNT IS: ' + grq.getRowCount());
if (grq.getRowCount() > 0) {
grq.eventQueue("Custom Table Notification", grq, null, null);
}
1. When I checked the email logs there were hundreds of emails in the logs. I want just one email if there is a new record created that day.
2. Is it possible when I do the above to include fields from the custom table for multiple records from the custom table all into that one notification?
Was going to use a business rule to trigger the event but I think it would end up triggering an event for each record insert, which is not what I want, so I switched to a fix script. Tried gs.eventQueue in the string above, and that did nothing.
Thanks
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2019 01:38 PM
This is presuming an import of data will run at a certain time daily. So that table shouldnt be touched otherwise. Are you sure about that? I think it does run for today, meaning that the scheduled job will run at say 10AM, for which it will check from 00:00 to 24:00 that same day. Are you saying thats not the case?