- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2020 11:13 AM
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.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2020 12:11 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2020 12:11 PM
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