- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2022 09:50 AM
I have a business rule running on the sysapproval_approver table after insert/update with the filter conditions:
Comments > changes
Approval for.Task type > is > Change Request
created to update the "CAB Recommendation" field on the change request form when it gets approved by our change manager. Here is the script I used:
// Adding approval comment to CAB recommendation field on change request record
var updateInitiatedBy = updateInitiatedBy || current.sys_id.toString();
(function executeRule(current, previous /*null when async*/ ) {
if (updateInitiatedBy != current.sys_id.toString()) {
return;
}
var gr = new GlideRecord('change_request');
gr.get(current.sysapproval);
gr.addQuery('approval','requested');
gr.cab_recommendation = current.comments.getJournalEntry(1);
gr.setWorkflow(false);
gr.update();
})(current, previous);
Right now it is currently populating the field like so:
I need to modify this script so that only the comment gets populated but not the time, approver, reply from, etc. All of the information at the top and bottom (Ref:MSG268) I want to remove from the field. How can I achieve this?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2022 10:04 AM
Try below
(function executeRule(current, previous /*null when async*/ ) {
if (updateInitiatedBy != current.sys_id.toString()) {
return;
}
var gr = new GlideRecord('change_request');
gr.addQuery('sys_id', current.sysapproval);
gr.addQuery('approval', 'requested');
gr.query();
if (gr.next()) {
var getcomments = new GlideRecord('sys_journal_field');
getcomments.addQuery('element_id', current.sys_id);
getcomments.addQuery('element', 'Comments');
getcomments.query();
if (getcomments.next()) {
gr.cab_recommendation = getcomments.value;
gr.setWorkflow(false);
gr.update();
}
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2022 10:04 AM
Try below
(function executeRule(current, previous /*null when async*/ ) {
if (updateInitiatedBy != current.sys_id.toString()) {
return;
}
var gr = new GlideRecord('change_request');
gr.addQuery('sys_id', current.sysapproval);
gr.addQuery('approval', 'requested');
gr.query();
if (gr.next()) {
var getcomments = new GlideRecord('sys_journal_field');
getcomments.addQuery('element_id', current.sys_id);
getcomments.addQuery('element', 'Comments');
getcomments.query();
if (getcomments.next()) {
gr.cab_recommendation = getcomments.value;
gr.setWorkflow(false);
gr.update();
}
}
})(current, previous);