- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2015 12:29 PM
Hello All,
I could use some help. I have been trying to get a rejected notification email to include the approver's rejection comments. I have tried several scripts to get his to work without fruitful results. The notification is targeting the sysapproval_approver table.
I tried the tree picker and then previous articles on the community to find an answer that works.
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
gr.addQuery('comments', current.comments);
gr.query();
if(gr.next()){
template.print("Rejected comments: " + gr.comments.getJournalEntry(1);
}
Thanks for any help.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2015 12:52 PM
Try removing the gr.addQuery('comments;, current.comments);
once you return from the query(), then just get the comments.
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
gr.addQuery('comments', current.comments); Remove this line
gr.query();
if(gr.next()){
template.print("Rejected comments: " + gr.comments.getJournalEntry(1);
}
If you still have trouble getting the comments, try setting getJournalEntry to -1;
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2015 12:43 PM
The route I took was:
1: The rejection note was added to the comments field.
2: Copy the contents of the comments field to the work note field of the parent.
3: Send a notification, when work_notes changes.
If you would like to use this, here is the script:
Condition: current.comments.changes() && (!current.sysapproval.isNil()) && current.sysapproval.sys_class_name == 'change_request'
Script:
var gr = new GlideRecord('change_request');
gr.get(current.sysapproval);
gr.work_notes = current.comments;
gr.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2015 12:48 PM
Thank you, but I may not be able to get the process you suggest to fly with my superiors. They want to keep work notes separate from the rejection comments.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2015 12:52 PM
Try removing the gr.addQuery('comments;, current.comments);
once you return from the query(), then just get the comments.
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
gr.addQuery('comments', current.comments); Remove this line
gr.query();
if(gr.next()){
template.print("Rejected comments: " + gr.comments.getJournalEntry(1);
}
If you still have trouble getting the comments, try setting getJournalEntry to -1;
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2015 01:03 PM
Thanks Tom.
I set it up as a new email script:
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
gr.query();
if(gr.next()){
template.print("Rejection comments: " + gr.comments.getJournalEntry(1));
}
Then referenced it in the notification body:
${mail_script:rejected_comments_from_journal_entry}