Update Business service for a closed incident

RAJIV MENON
Kilo Contributor

Hi, 

 

I have a bunch of closed incidents for which the business service is marked incorrectly or left blank. Is there a way to update the business service field for a closed incident. 

 

Thanks

2 REPLIES 2

Sujatha V M
Kilo Patron
Kilo Patron

@RAJIV MENON  Please use fix script to update the records. 

 

var gr = new GlideRecord('<table name>');
gr.addEncodedQuery('the query for the tasks that needs to be updated.'); //In case all the "Closed" incidents needs to be updated with same value. If not group it accordingly and update. 
gr.query();
gs.log("Rows count: " +gr.getRowCount()); //Validate if it matches as per the query results. 
while(gr.next()){
gr.<fieldname> = "<sys_id_of_the_business_service";
gr.setWorkflow(false);
gr.update();
}

 Reference : https://www.servicenow.com/docs/bundle/xanadu-application-development/page/build/applications/concep...

 

Note: You can use background scripts as well but its preferably "Fix scripts". 

 

 

Please mark this as helpful and accept it as a solution if this resolves your query.
Sujatha V.M.

Brad Bowman
Kilo Patron
Kilo Patron

Try the System Data Management -> Update Jobs in the left nav for a condition-based, script-less approach, with the ability to rollback!

BradBowman_0-1734783650115.png