How to call an eMail Template from a Mail Script

Peter Williams
Kilo Sage

I would like to know how we can call a eMail Template through a Mail Script for the purpose to have customized emails being sent through the workflow.

1 ACCEPTED SOLUTION

Milind Gharte
Kilo Guru

Hi,

Would it make sense to store that release date in a field on the form? That would make the email easier. You could set it with a business rule. The core script is going to be about the same, but it only needs calculating once, is visible on reports, and easier to retrieve in the email if you've got it on a field on the record.

Just my architectural thoughts.


The business rule would be something like this: (Note this is untested)

Name: Set release date

Table: (your table name)

When: before

Insert: true

Update: false

Advanced: true

Condition: (empty)

Script:

(function executeRule(current, previous /*null when async*/) {

var release = new GlideDateTime(current.sys_created_on);

release.addDaysLocalTime(3);

current.u_release_date = release;

})(current, previous);

The mail script method would be similar:

var release = new GlideDateTime(current.sys_created_on);

release.addDaysLocalTime(3);

template.print(release.getDisplayValue());

 

If it helps,Please mark Correct and 👍 Helpful.

Warm Regards,

Milind

View solution in original post

5 REPLIES 5

Milind Gharte
Kilo Guru

Hi,

Would it make sense to store that release date in a field on the form? That would make the email easier. You could set it with a business rule. The core script is going to be about the same, but it only needs calculating once, is visible on reports, and easier to retrieve in the email if you've got it on a field on the record.

Just my architectural thoughts.


The business rule would be something like this: (Note this is untested)

Name: Set release date

Table: (your table name)

When: before

Insert: true

Update: false

Advanced: true

Condition: (empty)

Script:

(function executeRule(current, previous /*null when async*/) {

var release = new GlideDateTime(current.sys_created_on);

release.addDaysLocalTime(3);

current.u_release_date = release;

})(current, previous);

The mail script method would be similar:

var release = new GlideDateTime(current.sys_created_on);

release.addDaysLocalTime(3);

template.print(release.getDisplayValue());

 

If it helps,Please mark Correct and 👍 Helpful.

Warm Regards,

Milind