Add additional comments via script on requested items by disabling notifications
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2022 02:18 AM
I want to add additional comment on requested items in bulk by disabling comments.
I am trying using scheduled job as below script but additional comments are not coming
var sc_req_item = new GlideRecord('sc_req_item');
sc_task_gr.addEncodedQuery("request.requested_for=javascript:gs.getUserID()^active=true^number=RITM0123312");// number of RITM on which comment shoulf go i.e. query
sc_req_item_gr.query();
while (sc_req_item_gr.next()) {
gs.log('Auto-reassign Scheduler : auto-reassigning the task record as part of request number- for '+sc_req_item_gr.getValue('req number'));
sc_req_item_gr.setValue('Additional comments','This ticket was closed unintentionally as part of a clean-up activity. As part of the correction the ticket has been re-opened at the same state, we apologize in advance for any inconvenience caused');//additional comment on RITMs
sc_req_item_gr.update();
}
Please guide how I can achieve this
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2022 04:16 AM
Yes you can use if that is required to run quite often, if it is a one time job then use fix script as well.
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2022 03:57 AM
I am using below scheculed job script
var requested_item = new GlideRecord('sc_req_item');
requested_item.addEncodedQuery("number=RITM0123315");
//RITM - Query
//active=true^assignment_group=2402bad7db22d094ed78ee805b9619c3^ORassignment_groupLIKEHIVE^request_item.sys_created_on<javascript:gs.beginningOfThisYear()^request_item.active=true
requested_item.query();
while (requested_item.next()) {
var id = requested_item.request; // store the sys_id of REQ which is related to RITM
requested_item.comments = 'This ticket was closed unintentionally as part of a clean-up activity. As part of the correction the ticket has been re-opened at the same state, we apologize in advance for any inconvenience caused.';
//cancel all the approvals for this request
requested_item.update();
}
It is adding additional comment but triggering notification as well. How can I disable notification

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2022 04:15 AM
Add
requested_item.setWorkflow(false) before requested_item.update();
so code will be
requested_item.setWorkflow(false);
requested_item.update();
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2022 04:21 AM
var requested_item = new GlideRecord('sc_req_item');
requested_item.addEncodedQuery("number=RITM0123314");
requested_item.query();
while (requested_item.next()) {
var id = requested_item.request; // store the sys_id of REQ which is related to RITM
requested_item.comments = 'This ticket was closed unintentionally as part of a clean-up activity. As part of the correction the ticket has been re-opened at the same state, we apologize in advance for any inconvenience caused.';
requested_item.setWorkflow(false);
requested_item.update();
}
Its not updating additional comments (customer visible) now when I use requested_item.setWorkflow(false);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2022 04:49 AM
Hi Ankita,
Unfortunately you need to tweak your notification to make sure it doesn't trigger when adding comment as setWorkflow(false) won't update comments due to behavior. go through below links
https://community.servicenow.com/community?id=community_article&sys_id=44ce5c051b718810a59033f2cd4bcbdf
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0867584
Regards
Regards,
Musab