how to bulk close incidents

srinivasd
Kilo Explorer

how to bulk close incidents

6 REPLIES 6

Aanchal Mehndi1
Giga Contributor

You can use sample code below and modify it according to your requirement and ran it in background script..



  1. var gr = new GlideRecord('incident');  
  2.   gr.addQuery('sys_updated_on', '<', <a number of days>);  
  3.   gr.query();  
  4.   while(gr.next()) {  
  5.   gr.active = false;  
  6.   gr.closed_by = gr.resolved_by;  
  7.   gr.update();    
  8.   }

vinitha3
Tera Guru

Hi,



Please explain the cause,



This would be the idea:



A Job scirpt/back ground script to update the incidents that fall under this category. You may need to update the close code or close notes to do so.



Thanks,


Vinitha.K


jyoti29208
Giga Expert

Hi Durga,



Either you can run a background script to do the same which is already provided by Aanchal or you can create buisness rule .


This article might be helpful for you :


http://wiki.servicenow.com/index.php?title=Closing_Multiple_Incidents#gsc.tab=0


The conditions can be modified according to your requirements.



Thanks,


jyoti kumari



PS: Hit like, Helpful or Correct depending on the impact of the response


babloo
Giga Contributor

Hi Durga



Please try this code:



var gr   = new GlideRecord('incident');  


gr.addQuery('state','resolve');  


  gr.query();  


while (gr.next()) {  


gs.print(gr.getRowCount());


gr.active=false;


  gr.update();    


}



I hope this will helpful



Thanks and Regards


Pavani Paluri