- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 08:22 PM
Hello,
We have a notification that triggers on the sysapproval_approver table. If a comment is added to the RITM record, we would like to capture it in the notification. We have tried the following code, but it did not work. Can someone please help? Thank you.
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var ritm = new GlideRecord('sc_req_item');
if (ritm.get(current.request_item)) {
// 'ritm' now contains the related RITM record
var comments = [];
var commentGr = new GlideRecord('sys_journal_field');
commentGr.addQuery('element_id', ritm.sys_id);
commentGr.addQuery('element', 'comments');
commentGr.query();
while (commentGr.next()) {
comments.push(commentGr.value);
}
template.print(commentGr.value);
}
})(current, template, email, email_action, event);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 09:12 PM
Hi @Erica2
please use the short notation:
template.print(current.sysapproval.comments.getJournalEntry(1));
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 08:35 PM
Hi,
Change the below statement to
template.print(commentGr.value); to template.print(comments.join(","));
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 09:02 PM
Hello @Saurabh Gupta
I made a mistake. I need help retrieving the work notes that were added to the RITM record on to the notification that triggered on the sysapproval_approver table. Could you please help? Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 09:12 PM
Hi @Erica2
please use the short notation:
template.print(current.sysapproval.comments.getJournalEntry(1));
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 09:17 PM
Hello @Maik Skoddow
I think I made a mistake somewhere in the code that made it print "blank"
var ritm = new GlideRecord('sc_req_item');
if (ritm.get(current.request_item)) {
// 'ritm' now contains the related RITM record
var comments = [];
var commentGr = new GlideRecord('sys_journal_field');
commentGr.addQuery('element_id', ritm.sys_id);
commentGr.addQuery('element', 'comments');
commentGr.query();
while (commentGr.next()) {
comments.push(commentGr.value);
}
template.print(current.sysapproval.comments.getJournalEntry(1));
}