Reopen incident from background script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2017 02:41 PM
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
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2017 02:49 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2017 03:06 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2017 09:06 AM
Surendra,
- 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
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2017 04:41 PM
Thanks Souren for suggestion and answer for this , will check this on personal instance first