Business Rule triggered two times, updating the work twice
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2023 11:05 PM
(function executeRule(current, previous /*null when async*/ ) {
var comment = new GlideRecord('sc_req_item');
comment.addEncodedQuery('request=' + current.request + '^cat_item=7d3212551b68a1d0923e6311f54bcbda');
comment.query();
if (comment.next()) {
comment.work_notes = current.number + ' has been marked as Closed Complete';
comment.update();
gs.info('doctorDoom ' + current.number + ' has been marked as Closed Complete');
}
})(current, previous);
This is the code I am using, but it is updating the work notes twice in the RITM table. May I know why this is happening, is this something I need to change in my code? I have checked logs as well it is populating the notes twice
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2023 12:56 AM
HI Ahmmed,
Thank you for your response but it's still updating the work notes twice

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2023 03:05 AM
Just remove the Comment.update(); statement from the script. Since BR is running before update. Update is running two times. One as you update and second in the script.
Regards,
Ashir Waheed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2023 05:30 AM
Thanks for your response, if I tried removing comment.update, now it is not updating the notes at all