Schedule Job

P1234
Tera Contributor

I need send a email notification regarding work anniversary at a time 100 employee using schedule job ?

 

Any idea how to build the above task.

2 REPLIES 2

Yashraj
Tera Expert

Hi @P1234 ,

Could you be more specific on what task are you talking about or can you please attach a screenshot of it?

Thanks,

Yashraj

P1234
Tera Contributor

Hi Yashraj,

 

send a notification to 100 users at a time regarding work anniversary using scheduled job code.

 

var user = new GlideRecord('sys_user');
user.addEncodedQuery('work_start_dateRELATIVEEE@today');
user.setLimit(100);
user.query();

while (user.next()) {
// Send notification logic
var notification = new GlideRecord('sys_notification');
notification.initialize();
notification.to = user.email;
notification.subject = 'Work Anniversary';
notification.body = 'Congratulations on your work anniversary!';
notification.insert();
}

 

But code is not working any idea please send me the exact code.