Background script to update additional comments for closed RITM's

D Sha
Tera Contributor

Hi,

 

I have a requirement from customer wherein they want to update the additional comments/work notes of around 200 closed RTIM's. So if I set the workflow(false), the work notes/additional comments get updated only on the list view of the RITM's and not on the RITM records and if I set the workflow(true), the comments do get updated but the notifications get triggered and this is not that big of an issue for the customer.

My main concern is that when I am trying to update all 200 records, only the last RITM gets updated. So at a time only one record is getting updated that is the last one in the query. 

I am not very fluent with scripting, but I did try the solutions already provided in community, but nothing works. 

 

Please help!

 

Script i am using:-

 

var gr = new GlideRecord('sc_req_item');
gr.addEncodedQuery('numberINRITM0474770,RITM0474562,RITM0474417,RITM0474240,RITM0474163,RITM0473853,RITM0473649,RITM0473584,RITM0473158,RITM0472588,RITM0472416,RITM0472415,RITM0472209,RITM0472117,RITM0472039,RITM0471999,RITM0471410,RITM0471389,RITM0470994,RITM0470780,RITM0470409,RITM0470328,RITM0470253');
gr.query();
while (gr.next()) {
gr.comments='SQL Server-Script executed';
gr.setWorkflow(true);
gr.autoSysFields(false);
gr.update();
}

 

In this case only 'RITM0470253' comments get updated

7 REPLIES 7

Animesh Das2
Mega Sage

Hi Dhriti,

If your only objective is to update those 200 RITMs, you have an easy way to do so and you don't need a background script or any script at all. Just search the RITMs in 'sc_req_item' table in list view with the numbers (if not 200 at one go then may be in chunks) in list view query builder. Then select all the records and open list context menu and use 'Update All' option to update all of those at one go with just filling 'Additional comments' field.

AnimeshDas2_0-1727112759520.png

 

If this helps, please mark this response correct by clicking on Accept as Solution and/or Kudos.



Thanks, 

Animesh Das

This does the job, but it triggers the emails. Although its not a prob here but if there is a way to do this without triggering the notifications then I'll prefer that. 

thanks

Hi @D Sha,

 

I am not sure if there is any way to stop emails triggering for particular bulk updates on a table. If you really want to stop triggering the emails I'd suggest do this activity in off business hours or on weekend and disable email sending from email properties as below.

AnimeshDas2_0-1727169409053.png

Then use the 'Update all' option to update the records at one go. It will hardly take any time and you enable the email sending back.

No need of unnecessary scripting which will do the same job basically.

 

If this address your question, please mark this response correct by clicking on Accept as Solution and/or Kudos.

You may mark this helpful as well if it helps you.

Thanks, 

Animesh Das