Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Send notification using Schedule Job.

itsangeleye
Giga Contributor

How can we generate a notification for the manager of the 'Requested For' user when a Requested Item (RITM) for a specific catalog item has a start date between 5 to 6 days ago?

1 ACCEPTED SOLUTION

Rushi Savarkar
Kilo Sage
Kilo Sage

Hello @itsangeleye 

Please find below code and let me know if that works for you

Schedule job:

var gr = new GlideRecord('sc_req_item');
gr.addQuery('cat_item', '620c2fb4c39b5a1004c43132b40131d1'); // replace your catalog item sys_id
gr.addQuery("variables.effe2774c35f5a1004c43132b4013141", "<=", gs.daysAgo(5)); //replace your start date variable sys_id
gr.query();
gs.info(gr.getRowCount());
while (gr.next()) {
gs.eventQueue('send.notification.demo', gr, gr.variables.manager, ''); // Event should be created
}

Thank you!

If my response helped you, please accept the solution and mark it as helpful.
Thank You!

View solution in original post

5 REPLIES 5

GlideFather
Tera Patron

@itsangeleye 
You can create a flow and set it accordingly.
Or a workflow, depending what is in use for your instance

Let me know how you progress and if you need to consult some steps

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */