- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2017 07:11 AM
I have the following <mail_script>in my Workflow Notification:
<mail_script>
//get the related approvals for this change
//check for any reject and display comments
//create a new glide record query for approval records
var appr = new GlideRecord('sysapproval_approver');
//get approvals for this change
appr.addQuery('sysapproval',current.sys_id);
//get rejected approvals
appr.addQuery('state','rejected');
//execute the query
appr.query();
//process each result if there are any
if (appr.next()) {
//print the approval info to the email message
template.print('Approver: ' + appr.approver.getDisplayValue() + '\n');
template.print('State: ' + appr.state) + '\n';
template.print('Comments: ' + appr.comments + '\n');
template.print('\n');
}
</mail_script
It is returning the following:
The field I am pulling in from is:
Thank you in advance for your help on this issue.
Troy
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2017 05:37 AM
Hi Troy try changing the gs.log to template.print as below
<mail_script>
//get the related approvals for this change
//check for any reject and display comments
var notes;
//create a new glide record query for approval records
var appr = new GlideRecord('sysapproval_approver');
//get approvals for this change
appr.addQuery('sysapproval',current.sys_id);
//get rejected approvals
appr.addQuery('state','rejected');
//execute the query
appr.query();
//process each result if there are any
while (appr.next()) {
var je = new GlideRecord('sys_journal_field');
je.addQuery('element_id', appr.sys_id);
je.addQuery('elements', 'comments');
je.addQuery('name', 'sysapproval_approver');
je.query();
if(je.next()){
notes = je.value;
}
//print the approval info to the email message
template.print('Approver: ' + appr.approver.getDisplayValue() + '\n');
template.print('State: ' + appr.state) + '\n';
template.print('Comments: ' + notes + '\n');
template.print('\n');
}
</mail_script>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2017 07:15 AM
You need to loop thorugh the records..try changing code below
FROM
if (appr.next()) {
TO
while (appr.next()) {
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2017 07:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2017 07:26 AM
try with changing if (appr.next()) to While (appr.next()). it will execute till you have matching records and IF will do for once only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2017 07:37 AM
That did not work, same results