Template.Print font setting for comments_work_notes

Bridget6
Kilo Expert

I am attempting to create an email script that will set the font for comments and work notes from change requests in an email notification. The script below will add the comments but it will not set the font. Would really appreciate any assistance with getting the font set so it matches the rest of the notification.

 

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {


template.print('<p><span style="font-family: arial, helvetica, sans-serif; font-size: 10pt;">${comments_and_work_notes}</span></p>');

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

12 REPLIES 12

The script you provided seems to work on every field except work notes. Thanks for replying.

EraShawn
Tera Contributor

I was running into the same problem trying to display the latest worknote from an incident in a notification while trying to use gr.work_notes.getJournalEntry(1) which similarly works for the additional comment but not for the work notes as noted in a reply above. I found another article talking about the sys_journal_field table, so instead of relying on the built in getJournalEntry function, I decided to query the table itself. Using this method, the html formatting of the work notes value was successful. Trying using this code as I have in an email script. It was painful running so many tests and not getting the worknotes to format so hopefully this will spare you hours of frustration.

 

var desc2 = '';
var gr = new GlideRecord("incident");
gr.addQuery("number", current.number);
gr.query();
while(gr.next()) {

var wn = new GlideRecord("sys_journal_field");
wn.addQuery("element_id", gr.sys_id);
wn.orderByDesc('sys_created_on');
wn.setLimit(1);
wn.query();
while(wn.next()) {
desc2 += wn.value;
}

}

template.print("<span style='font-family: arial, helvetica, sans-serif; font-size: 12pt;'>" + desc2 + "</span>");

 

Thanks for this! It's definitely a step in the right direction but doesn't work the same for change_request as it does for incident. It's bringing in all of the approvals as well as the comments and work notes. I will keep working on it using your example though. Again, thanks.