Change Date Format in only for specific notification

Aditya37
Tera Contributor

Hello everyone,

We have a notification for the Change Request table that requires a modification. In the email body, the CAB Date field should be displayed in MM DD YYYY format exclusively for this notification. Currently, it is showing in the YYYY MM DD format.

Please refer to the screenshot below for more information. Can anyone please assist me with this?

Thanks in advance.

 

Aditya37_0-1699598853482.png

 

2 ACCEPTED SOLUTIONS

Anand Kumar P
Giga Patron
Giga Patron

Hi @Aditya37 ,

Create an email script and write below script

 

var cabdate = new GlideDateTime('replacewith out date field');
var fd = new GlideDateTime(cabdate);
var dateToPrint = fd.getDate();
var get = dateToPrint.getByFormat('MM-dd-yyyy'); 
template.print(get);

In notification body-------------
${mail_script:mailscriptname}

AnandKumarP_0-1699600621008.png

 

 

Please mark it as helpful and solution proposed if it serves your purpose.

Thanks,

Anand

View solution in original post

Ankur Bawiskar
Tera Patron
Tera Patron

@Aditya37 

you will require email script for this and then include that email script in email body

I hope you know how to create email script and include in email body syntax is ${mail_script:mailScriptName}

Check on docs if any query

In email script do this

var cabDt = new GlideDateTime(current.cab_date_time);
		var dt = new GlideDate(cabDt.getDate());
		var myFormatValue = dt.getByFormat('MM-dd-yyyy');	
		template.print('See below for the status of CAB date: ' + myFormatValue);

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

View solution in original post

4 REPLIES 4

Anand Kumar P
Giga Patron
Giga Patron

Hi @Aditya37 ,

Create an email script and write below script

 

var cabdate = new GlideDateTime('replacewith out date field');
var fd = new GlideDateTime(cabdate);
var dateToPrint = fd.getDate();
var get = dateToPrint.getByFormat('MM-dd-yyyy'); 
template.print(get);

In notification body-------------
${mail_script:mailscriptname}

AnandKumarP_0-1699600621008.png

 

 

Please mark it as helpful and solution proposed if it serves your purpose.

Thanks,

Anand

@Anand Kumar P 

Thank you for the quick response.
Thank you so much for your help! Your solution was perfect and exactly what I needed. I appreciate your expertise.

Thanks😊!

Thank You!

Ankur Bawiskar
Tera Patron
Tera Patron

@Aditya37 

you will require email script for this and then include that email script in email body

I hope you know how to create email script and include in email body syntax is ${mail_script:mailScriptName}

Check on docs if any query

In email script do this

var cabDt = new GlideDateTime(current.cab_date_time);
		var dt = new GlideDate(cabDt.getDate());
		var myFormatValue = dt.getByFormat('MM-dd-yyyy');	
		template.print('See below for the status of CAB date: ' + myFormatValue);

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

@Ankur Bawiskar 

Thanks for the quick response.

Your solution was exactly what I needed, and I can't thank you enough for your assistance. Your expertise is greatly valued!

Thanks😊!