Creating Schedule job to send notification.

prabhmeet
Giga Expert

Hi,

I have to create a scheduled job which will run daily to send a notification to the caller of the incident, if the ticket is in active state for more than 5 days.

Below is the script I have written in the Schedule job-

var gr = new GlideRecord('incident');
gr.addQuery('state', 'Active');
gr.addQuery('sys_created_on', '<', gs.daysAgo(5));
gr.query();
while(gr.query()){
gs.eventQueue('Incident.Active',gr, '','');
}

 

I have registered an event called Incident.Active and created a notification. I have not added any condition/script in the notification.This is not working though. Can someone please explain me my mistake?

I am very new to Servicenow and any help is appreciated. 

17 REPLIES 17

Nilanjan1
Mega Sage

Hello All, 

I was going through the post and it seems to be very helpful, I am also trying to create a kind of a notification which triggers every year on a list of cloud applications business owners . I created a scheduled jobs and an event and a notification, however when the execute a scheduled job the firing of the event or the notification is not happening. Any leads to this. this is what I have used as a steps: 

 

var gr = new GlideRecord('u_cloud_applications');
gr.addEncodedQuery('u_business_ownerISNOTEMPTY');
gr.query();
while(gr.next()){
	gs.eventQueue('Cloud Application Notification',gr);
}

cloud application notification is the Event. 

Regards

Nilanjan

Hi Nilanjan,

Event Registry name should not contain space.

like : Cloud Application Notification     

it must be as like : Cloud.Application.Notification

that's why event not getting fired

kalaiselvi Ravi
Tera Contributor

InsteadOf two addQuery methods,Can You use encodedQuery  or use and condition to  make it as a single Query