Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Script Needed

Saib1
Tera Guru

HI All,

 

I need a script to update the incident table

 

Requirement:

 

I need to capture the updated time and add it in closed field

1 REPLY 1

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

Try something like this in a fix script.

Please test once with one record before running it for bulk.Try in lower instance before running it on prod

updateINC();

function updateINC(){

	try{
		var gr = new GlideRecord('incident');
		gr.addEncodedQuery("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); //Add records or filter you want to update
		gr.query();
		var count = 0;
		while(gr.next()){
			count++;
			gr.closed_at=gr.sys_updated_on;
			gr.setWorkflow(false);
			gr.setUseEngines(false); // to prevent data policy from blocking the update
			gr.update();
		}
		gs.info('Total INC updated' + count);
	}
	catch(ex){
		gs.info('exception' + ex);
	}
}
-Anurag