Reopen incident from background script

sr_surendra
Giga Expert

Dear all,

I want to reopen the closed incident , I have 2 questions regarding this

1)there are different email notifications configured on this , I don't want those to be triggred when I reopen this incident , is this possible when incident reopens through background script.

2) From several records of incident numbers I want only one perticular incident to be opened , how can we do that

please help me I am new to this "Background script concept"

Regards,

Surendra

4 REPLIES 4

Michael Ritchie
ServiceNow Employee
ServiceNow Employee

Pull up the incident, click Additional Actions and choose Copy SysID, this will put it into your computer clip board.



Paste this into your favorite text editor.   Then paste in the following script below and put the SysID into the variable at the top:


var incidentSysID = "PUT INCIDENT SYSID IN HERE";



var incidentRec = new GlideRecord("incident");


incidentRec.addQuery("sys_id", incidentSysID);


incidentRec.query();


while (incidentRec.next()) {


  incidentRec.state = 2;   //2 = In Progress, 6 = Resolved


  incidentRec.active = true;


  incidentRec.autoSysFields(false);   // Do not update sys_updated_on, sys_updated_by, and sys_mod_count


  incidentRec.setWorkflow(false);       // Do not run any other business rules


  incidentRec.update();


}



You will notice I use autoSysFields which will not update the dates and I also use setWorkflow(false) will NOT run business rules so notifications won't go out.


Thanks Michael,



I will check this


Could you please let me know if incident state is changed through this script, will it trigger email notifications configured for event state change for incident



Regards,


Surendra


Surendra,



  1.   incidentRec.autoSysFields(false);   // Do not update sys_updated_on, sys_updated_by, and sys_mod_count  
  2.   incidentRec.setWorkflow(false);       // Do not run any other business rules


These two statements doesnt run any server side script and updated time, updated by fields doesnt get updated. Notifcation gets triggered through updated time or event (server side script).



It should not trigger any notification. For confirmation you can run it on personal instance first and apply in Production.



Regards,


Souren



Please mark this post or any post helpful or the correct answer so others viewing can benefit.


Thanks Souren for suggestion and answer for this , will check this on personal instance first