create a notification expire in 30, 60, 90 days remainder.

RadhaV
Tera Contributor

When  we have certificate that will expire in 30, 60, 90 days, we need to set remainders.

1 ACCEPTED SOLUTION

Tanushree Maiti
Tera Patron

Hi @RadhaV 

 

Try this:

 

1: Register the Event

  • Navigate to System Policy > Events > Registry>Click New.
  • Event name: record.expiry.reminder
  • Table: Select your target table (like sc_req_item, alm_asset, custom_table_name).
  • Description: Trigger for 90, 60, and 30 days before expiration.

 

2: Create the Email Notification

  • Navigate to System Notification > Email > Notifications.>Click New.
  • Table: Select the same target table.
  • When to send: Select Event is fired.
  • Event name: Choose record.expiry.reminder (created in Step 1).
  • Who will receive: Select the users/groups (e.g., Assigned to, or Manager).
  • What it contains: Draft your message (e.g., "This is a reminder that your record is expiring in [Event.parm1] days.").

 

3: Create the Scheduled Job (Scheduled Script Execution)

  • Navigate to System Definition > Scheduled Jobs>New
  • select Automatically run a script of your choice.
  • Fill in the Name (e.g., Record Expiry 90/60/30 Day Reminders), set the interval to Period (1 Day),

 

var gr = new GlideRecord('your_custom_table_name'); // Replace with your target table

gr.addActiveQuery();

gr.addQuery('u_expiration_date', 'ISNOTEMPTY'); // Replace with your actual date field

gr.query();

while (gr.next()) {

    var expDate = new GlideDateTime(gr.getValue('u_expiration_date'));

    var today = new GlideDateTime();

        var diff = gs.dateDiff(today.getDisplayValue(), expDate.getDisplayValue(), true);

    var daysRemaining = Math.ceil(diff / 86400);

    if (daysRemaining == 90 || daysRemaining == 60 || daysRemaining == 30) {

        gs.eventQueue('record.expiry.reminder', gr, daysRemaining, gs.getUserID());

    }

}

 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

View solution in original post

4 REPLIES 4

Sandeep Rajput
Tera Patron

@RadhaV You can create a scripted schedule job to fetch the certification expiration date and trigger the notification after every 30/60/90 days.

 

You can refer to this article https://nishacodeblogs.medium.com/send-notification-on-specific-day-date-in-servicenow-5d909d609f0b to take some inspiration.

RadhaV
Tera Contributor

site is blocked.

 

Ankur Bawiskar
Tera Patron

@RadhaV 

you can have event configured on your table along with notification

Then have daily scheduled job with sample script below, please enhance

sendEmail();

function sendEmail(){
	try{
		var gr = new GlideRecord('tableName');
		gr.addQuery('Your Query');
		gr.query();
		while(gr.next()){
			var gdt = new GlideDateTime(gr.dateField);
			var nowTime = new GlideDateTime();

			var duration = GlideDateTime.subtract(gdt, nowTime);
			var days = duration.getDayPart();
			if(days == 30 || days == 60 || days == 90){
				gs.eventQueue("eventName", gr, gr.assigned_to.toString());
			}
		}
	}
	catch(ex){
		gs.info('Exception'+ex);
	}
}

💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Tanushree Maiti
Tera Patron

Hi @RadhaV 

 

Try this:

 

1: Register the Event

  • Navigate to System Policy > Events > Registry>Click New.
  • Event name: record.expiry.reminder
  • Table: Select your target table (like sc_req_item, alm_asset, custom_table_name).
  • Description: Trigger for 90, 60, and 30 days before expiration.

 

2: Create the Email Notification

  • Navigate to System Notification > Email > Notifications.>Click New.
  • Table: Select the same target table.
  • When to send: Select Event is fired.
  • Event name: Choose record.expiry.reminder (created in Step 1).
  • Who will receive: Select the users/groups (e.g., Assigned to, or Manager).
  • What it contains: Draft your message (e.g., "This is a reminder that your record is expiring in [Event.parm1] days.").

 

3: Create the Scheduled Job (Scheduled Script Execution)

  • Navigate to System Definition > Scheduled Jobs>New
  • select Automatically run a script of your choice.
  • Fill in the Name (e.g., Record Expiry 90/60/30 Day Reminders), set the interval to Period (1 Day),

 

var gr = new GlideRecord('your_custom_table_name'); // Replace with your target table

gr.addActiveQuery();

gr.addQuery('u_expiration_date', 'ISNOTEMPTY'); // Replace with your actual date field

gr.query();

while (gr.next()) {

    var expDate = new GlideDateTime(gr.getValue('u_expiration_date'));

    var today = new GlideDateTime();

        var diff = gs.dateDiff(today.getDisplayValue(), expDate.getDisplayValue(), true);

    var daysRemaining = Math.ceil(diff / 86400);

    if (daysRemaining == 90 || daysRemaining == 60 || daysRemaining == 30) {

        gs.eventQueue('record.expiry.reminder', gr, daysRemaining, gs.getUserID());

    }

}

 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti