Scheduled Job not triggering event for notification, when there is no time card record for the user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2022 11:06 AM
Hi, we need to get a notification on the end of the week, when forgot to submit time sheet for this week. So I followed below link to write a scheduled job and created an Event and Notification.
But I am getting error that parm1 is not defined.
Scheduled Job:
var gr = new GlideAggregate('sys_user_grmember');
gr.addEncodedQuery('groupLIKEServiceNOW-ITC-RM');
gr.addAggregate('COUNT', 'user');
gr.query();
while (gr.next()) {
var User = gr.user;
var gr1 = GlideRecord('time_sheet');
gr1.addEncodedQuery("week_starts_onONLast week@javascript:gs.beginningOfLastWeek()@javascript:gs.endOfLastWeek()^user=" + User);
gr1.query();
if (!gr1.hasNext()) {
gs.eventQueue('tc.norecord.thisweek', current, parm1, parm2);
}
}
Can anyone please suggest !!!!!!!!!
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2022 11:19 AM
Hi Chandan,
you didn't define then correctly, refer below example
gs.eventQueue('incident.manager.reminder', current, current.number, gs.getUserName());
//gs.eventQueue - adds an event to System Logs -> Events
//incident.manager.reminder - is the name of the event
//current.number - refers to the number of the task the business rule is running on - this is parm1
//gs.getUserName() - gets the username of the one who generated the event - this is parm 2
Kindly mark correct and helpful if applicable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2022 11:21 AM
Have you defined parm1 and parm2? 🙂 You should also have gr instead of current, and then you need to define what you want in parm1 and in parm2.
Best regards,
Sebastian Laursen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2022 11:48 AM
Example:
gs.eventQueue('tc.norecord.thisweek', gr, User, '');
Best regards,
Sebastian Laursen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2022 11:21 AM
Hi
your given source code
gs.eventQueue('tc.norecord.thisweek', current, parm1, parm2);
does not fit to the code in your screenshot:
gs.eventQueue('tc.norecord.thisweek', current.parm1.toString(), current.parm2.toString());
So what exactly is the issue?
Kind regards
Maik