Send notification 14 days before the expiry date (variable on record producer)

akash kaj
Tera Contributor

i want to send notification 14 days before the expiry date.Expiry date is the variable(type -Date) on record producer and it is a scoped application

9 REPLIES 9

AnubhavRitolia
Mega Sage
Mega Sage

Hi Akash,

You can right a Scheduled Job which will run once a days. 

In this Scheduled Job, write script to check that current Date is 14 days before Expiry Date. If yes, trigger new event using gs.eventQueue function and trigger email notification as per requirement.

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

i tried the below code but it is not working

find_real_file.png

Hello Akash,

I dont think so it is necessary to add the record producer query in thr GLideRecord try removing it.

As record producer is used just to create a record and once the record is created you can directly access the variables from the record created.

Please mark my response as helpful/correct, if it answer your question.

Thanks

 
If my answer solved your issue, please mark my answer as Correct & Helpful based on the Impact

Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.

Mahendra RC
Mega Sage

Hello Akash,

Please check once with below script:

(function () {
	var expiryDateGDT = new GlideDateTime();
	expiryDateGDT.addDays(14);
	var expiryDate = expiryDateGDT.getDate();
	var query = "task.variables.expiry_dateON" + expiryDate +"@javascript:gs.dateGenerate('" + expiryDate + "','start')@javascript:gs.dateGenerate('" + expiryDate + "','end')";
	
	var incidentGR = new GlideRecord("Your Table Name");
	incidentGR.addActiveQuery();
	incidentGR.addEncodedQuery(query);
	while (incidentGR.next()) {
		gs.eventQueue("Your EVENT name", incidentGR, "Your Recepient", "");
	}
	
})();

Please mark my respsone as helpful/correct, if it answer your question.

Thanks