Scheduled Job not triggering event for notification, when there is no time card record for the user

chandan15
Tera Contributor

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.

https://community.servicenow.com/community?id=community_question&sys_id=f4c9e320db46df804837f3231f96...

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);
    }
}

find_real_file.png

Can anyone please suggest !!!!!!!!!

6 REPLIES 6

Chetan Mahajan
Kilo Sage
Kilo Sage

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

Sebastian L
Mega Sage

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

Example:

gs.eventQueue('tc.norecord.thisweek', gr, User, '');

Best regards,
Sebastian Laursen

Maik Skoddow
Tera Patron
Tera Patron

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