Need to setup dynamic date value in email notification based on the event

nupur_goswami
Tera Contributor

Hi

 

I have a requirement where I need to trigger an email notification. On the email notification I need to mention due due,  date which should be date on which event is fired ( which will trigger the same email notification) +7days. 

I tried writing an email script but did not work, any suggestions would be appreciated.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@nupur_goswami 

I believe you know how to create and add email script to email body

Add like this (syntax below)

AnkurBawiskar_0-1743688269066.png

 

Script in email script

(function runMailScript(current, template, email, email_action, event) {

    // Add your code here
    var nowTime = new GlideDateTime();
    nowTime.addDaysUTC(7);
    template.print('Date is ' + nowTime.getDate());

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

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

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@nupur_goswami 

I believe you know how to create and add email script to email body

Add like this (syntax below)

AnkurBawiskar_0-1743688269066.png

 

Script in email script

(function runMailScript(current, template, email, email_action, event) {

    // Add your code here
    var nowTime = new GlideDateTime();
    nowTime.addDaysUTC(7);
    template.print('Date is ' + nowTime.getDate());

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

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

@nupur_goswami 

Hope you are doing good.

Did my reply answer your question?

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

@nupur_goswami 

Hope you are doing good.

Did my reply answer your question?

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

nupur_goswami
Tera Contributor

Hi @Ankur Bawiskar it works ! Thank you 
I have marked your response helpful