Adding the author name to the subject line of the email via mail script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2024 07:02 AM
Hello all,
I am trying to update the km_approval mail script's subject line to include the author's name.
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var obj = new KBKnowledge().getNotificationObject(current);
var emailContent = {};
emailContent.templateContent =
"Hi "+obj.approver+",<br/>" +
"<br/>" +
"<a href="+obj.article_link+">"+obj.number+"</a> is awaiting approval.<br/>" +
"<br/>" +
"<b>Article Title</b>: "+obj.short_desc+"<br/>" +
"<br/>" +
"Please review the article and <a href="+obj.approval_link+">Approve/Reject</a> it<br/>" +
"<br/>";
email.setSubject(obj.author+"has submitted"+ obj.number+" is awaiting approval.");
template.print(emailContent.templateContent);
})(current, template, email, email_action, event);
I have tried current.author, event.author, and email,author. Is there a specific way i need to access the object being called? Any insight would be greatly appreciated!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2024 07:49 AM - edited 08-02-2024 08:00 AM
Your current object is a sysapproval_approver gliderecord (You can see this by checking the table field of your notification). So you need to go to the kba from there.
Add:
var author;
var grKnowledge = new GlideRecord('kb_knowledge');
if(grKnowledge.get(current.document_id))
author = grKnowledge.author.getDisplayValue();
else
author = 'Someone';