- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2021 12:05 PM
Hello Experts,
I have requirement to hide name of HR agent hidden in email notification for "Case Commented".
If Additional Comment is added by "HR Agent" it should appear as "HR Agent" instead of User name.
If added by customer /opened_for, then display the name.
This needs to be in "Email". I tried using mail script but no success. Here is the mail script I got from another community post.
email is generated with following output
Solved! Go to Solution.
- Labels:
-
Instance Configuration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2021 01:04 PM
Oh that's an easy enough fix. Variable references are CAPS sensitive in javascript, another good reason to copy+paste your variables instead of typing them. Just match case and you should get rid of that error, because "ticketId" is completely different from "ticketID"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2021 11:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2021 11:57 AM
I'd recommend adding some other template.print()'s to debug: If it isn't getting to the getEncodedQuery() line, I'd check and see if the ticketID is what you expect. If it is, maybe the GlideRecord isn't able to query due to some scoping restrictions, in which case adding a try/catch statement around the query and gs.info()'ing the catch error might give you some insight.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2021 01:00 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2021 01:04 PM
Oh that's an easy enough fix. Variable references are CAPS sensitive in javascript, another good reason to copy+paste your variables instead of typing them. Just match case and you should get rid of that error, because "ticketId" is completely different from "ticketID"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2021 01:21 PM
Here is the final script in case anyone needed in future.
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,/* Optional GlideRecord */event) {
var ticketId =current.sys_id;
var journal = new GlideRecord('sys_journal_field');
journal.addQuery('element_id',ticketId);
journal.addQuery('element','comments'); //Provide name of the journal field, here the field name is 'comments'
//journalEntry.addQuery('element_id', 'ticketId'); //Provide sys_id of the record on which the journal field is present, i.e, sys_id of the change request
journal.query();
template.print('journal' +ticketId.value);
while(journal.next()) {
template.print('Comment : ' + journal.value);
//gs.print('Commented By : ' + journalEntry.sys_created_by);
template.print('Commented On : ' +journal.sys_created_on + '<hr>');
}
}) (current, template, email, email_action, event);