Join us Dec. 16 for The Community Hour, our first global virtual User Group event!

Custom notification query

cw82uk
Giga Expert

Hi,

We have auto reject enabled on catalogue approval models.  The approver receives reminder emails are intervals advising 'This is a reminder that you have a pending approval for the following request. 

Please note that this request will get auto-rejected soon.'.
Our customer would like to introduce the date that auto rejection will occur, or a count down, such as 'Please note that this request will get auto-rejected in x days.'.
Does anyone know of a script we could use?
Thanks
Chris
2 REPLIES 2

SVimes
Mega Sage

Have you tried a mail script that uses something like this?

 

	var gdt1 = new GlideDateTime(); //Now
	var gdt2 = new GlideDateTime("<expiration_date>");
	var dur = GlideDateTime.subtract(gdt1, gdt2);
	template.print(dur.getNumericValue() / (1000 * 60 * 60 * 24)); //Convert milliseconds to days, add Math.floor(<formula>) or Math.ceil(<formula>) to round down or up if needed

VaishnaviK3009
Kilo Sage

Hi @cw82uk ,

Yes, this can be handled through an Email Script in the approval reminder notification.

Calculate the remaining days based on the auto-rejection date and display it dynamically:

var rejectDate = new GlideDateTime(current.auto_reject_date);
var now = new GlideDateTime();

var diff = GlideDateTime.subtract(now, rejectDate);
var days = Math.ceil(diff.getNumericValue() / 86400000);

template.print('Please note that this request will get auto-rejected in ' + days + ' days.');

Add the mail script to the reminder notification:

${mail_script:Auto Reject Countdown}

If the auto-rejection date is not stored on the approval record OOB, calculate it using the configured auto-rejection interval.

 

Mark this as Helpful if it clarifies the issue.
Accept the solution if this answers your question.

Regards,
Vaishnavi
Technical Consultant