How to add a change task table in change email notification in workflow?
Import
·
Oct 02, 2019
·
article
How to add a change task table in change email notification in workflow?
| Image | Description |
|---|---|
| 01. Go to >> System Notification > Notification Email Scripts | |
| 02. New | |
| 03. Type a name | |
| 04. Type script following the sample code above using the ordinary GlideRecord and creating a HML table. | |
| 05. On the notification you need to use a sample code, using the format ${mail_script:} ${mail_script:type_the_script_name} |
Script
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var vchange = current.sys_id;
var vtask = new GlideRecord('change_task');
vtask.addQuery('change_request',vchange);
vtask.query();
template.print('<table border="1">');
template.print('<tbody>');
template.print('<tr>');
template.print('<td style="text-align: center; color: #ffffff; background-color: #002060;">TASK </td>');
template.print('<td style="text-align: center; color: #ffffff; background-color: #002060;">Assignee</td>');
template.print('<td style="text-align: center; color: #ffffff; background-color: #002060;">STATUS</td>');
template.print('<td style="text-align: center; color: #ffffff; background-color: #002060;">Close notes</td>');
template.print('</tr>');
while(vtask.next()){
template.print('<tr>');
template.print('<td>'+vtask.short_description+'</td>');
template.print('<td>'+vtask.assigned_to.name+'</td>');
template.print('<td>'+vtask.state+'</td>');
template.print('<td>'+vtask.close_notes+'</td>');
template.print('</tr>');
}
template.print('</tbody>');
template.print('</table>');
})(current, template, email, email_action, event);
View original source
https://www.servicenow.com/community/itsm-articles/how-to-add-a-change-task-table-in-change-email-notification-in/ta-p/2312413