Send Reminder approval emails for a particulat catalog item

Shivangi Singh2
Tera Contributor

My question is if I have to send lets say 3 reminder email for a particular RITM until it is approved , do i have to create 3 different notifications stating Reminder 1,2,3?

in the body or subject line we would like to add that it's a reminder email but i am not sure if there's any way where i can utilize current notification for reminder purpose also ,or do i have to create different template for all 3 reminders?

2 ACCEPTED SOLUTIONS

@Shivangi Singh2 
In the param 1 or param 2, pass the stringified JSON objects.

{
  "approver": "Approver detais",
  "subject": "Reminder 1"
}

 

Then in your email script, parse the JSON and use it as required.

var obj = JSON.parse(event.param2);
var approver = obj.approver;
var subject = obj.subject;

View solution in original post

Robert H
Mega Sage

Hello @Shivangi Singh2 ,

 

You only need a single Notification. You can pass the reminder number as a parameter and then based on whether it's 1, 2 or 3 you can have different subjects or messages in the email.

 

Example:

Create an Email Script, e.g. "my.approval.reminder":

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {


	var parameters = JSON.parse(event.parm1);
	var reminderNumber = parameters.reminderNumber;
	email.subject = 'Reminder #' + reminderNumber;

	if (reminderNumber === 1) {
		template.print('This is the first reminder.');
	}

})(current, template, email, email_action, event);

 

Include the above Email Script in the Message field of the Notification:

${mail_script:my.approval.reminder}

 

Then trigger the event that triggers the above Notification like this:

var parameters = {
	ritmSysId: '...',
	reminderNumber: 1
};
var approverSysId = '...';

gs.eventQueue('my.approval.reminder', current, JSON.stringify(parameters), approverSysId);

 

Regards,

Robert

View solution in original post

10 REPLIES 10

@Shivangi Singh2 
In the param 1 or param 2, pass the stringified JSON objects.

{
  "approver": "Approver detais",
  "subject": "Reminder 1"
}

 

Then in your email script, parse the JSON and use it as required.

var obj = JSON.parse(event.param2);
var approver = obj.approver;
var subject = obj.subject;

Ankur Bawiskar
Tera Patron
Tera Patron

@Shivangi Singh2 

you can send extra details in parm2 and then use email script to determine which reminder the email triggered for

then print the appropriate content

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

@Shivangi Singh2 

check this link

ARTICLE: Approval Reminder Email using Scheduled Job and Notification Email Script 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Robert H
Mega Sage

Hello @Shivangi Singh2 ,

 

You only need a single Notification. You can pass the reminder number as a parameter and then based on whether it's 1, 2 or 3 you can have different subjects or messages in the email.

 

Example:

Create an Email Script, e.g. "my.approval.reminder":

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {


	var parameters = JSON.parse(event.parm1);
	var reminderNumber = parameters.reminderNumber;
	email.subject = 'Reminder #' + reminderNumber;

	if (reminderNumber === 1) {
		template.print('This is the first reminder.');
	}

})(current, template, email, email_action, event);

 

Include the above Email Script in the Message field of the Notification:

${mail_script:my.approval.reminder}

 

Then trigger the event that triggers the above Notification like this:

var parameters = {
	ritmSysId: '...',
	reminderNumber: 1
};
var approverSysId = '...';

gs.eventQueue('my.approval.reminder', current, JSON.stringify(parameters), approverSysId);

 

Regards,

Robert

Thank you so much for the help @Robert H . I will try this solution and reply here