Post a comment on the RITM Approvers Tab when approval is created on the RITM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2025 12:10 PM
The requirement is to populate comment on the approver tab when An approval has been added before the SCTASK created.
"My business rule on "sc_req_item" table, shown below, is not populating the approver tab for all users. Only a few users are being populated, and it is also posting multiple comments on a single record."
How can I modify the script to populate comments once for all the approvers
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var approval = new GlideRecord('sysapproval_approver');
approval.addQuery('sysapproval', current.sys_id); // document_id on approval refers to the RITM
approval.query();
gs.info("Approval count" + approval.getRowCount());
if (approval.next()) {
// Copy RITM description to approval comment field
approval.comments = "Testing";
approval.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2025 01:15 PM
It's always considered as best practice in ServiceNow to use "setLimit(1)" if we are using "If" statement after the query. Try limiting. I hope too don't have anything to do with the count of the number of approvals?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2025 01:21 PM
As per your requirement, you can rather try writing an after insert Business Rule on sys_approval table.
In the BR, you can check if the related request item does not have sc_task created, then add a comment on your approval record.