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 05:33 AM
Okay Thanks alot for the update and the links shared.
So I cannot achieve this using scheduled job correct?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2022 05:59 AM
No, you can achieve it no problem.
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2022 06:08 AM
How can I achieve it?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2022 06:47 AM
Notification which is triggering try to add this in 'Advance condition' and then run job to see to see if comment is getting updated.
var comment = journalDissection(current.comments.getJournalEntry(1));
if(comment.startsWith('This ticket was closed unintentionally as part of a clean-up activity')){
answer = false;
}
else{
answer = true;
}
function journalDissection(journal){
var index = journal.indexOf('\n');
return journal.substring(index,journal.length).trim();
}
Regards,
Musab

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2022 06:40 AM
Try this