Add additional comments via script on requested items by disabling notifications

Ankita Gupte
Kilo Sage

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

23 REPLIES 23

I used this script and is working fine if I run query for single record.

But when I run query as system administrator for bulk record it is showing run by requested by user name for some records and I am running this script today on 9-4-2022 and the additional comment date is showing of 30-3-2022. The date at which ticket was open. Don't know why is this happening. Will you please help with the same.

find_real_file.png

On step 7 of the script I see there is a Log statement calling sc_req_item_gr, can you comment out this line or replace 'sc_req_item_gr' with 'requested_item' and try again?

sai12
Tera Contributor

 

Hi,

Can you Set Journal entry like below and see

 

requested_item.comments.setJournalEntry("Content of the journal entry.");

Please hit helpful if this works:)

This is triggering notification.

sai12
Tera Contributor

Please use setworkflow(false) before update and try.