
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2019 05:17 AM
Within Incident Management, we turned the state of "Awaiting User Info" (created, not OTB state) to Inactive status. There were over 400 tickets that were in that state, most of which were over 1 year old (put in that state by technician, then "forgotten")
We were able to get a Fix Script on this site that would convert all of those tickets from the old, inactive state to the Closed state so no emails would go out to the callers.
This worked just fine in our Development instance, so we cloned down our Production Instance to our Test Instance and ran the Fix Script in that instance.
However, the results were inaccurate this time. Instead of converting them to Closed state, they were convert to Canceled state. There are no emails turned on for this instance so no callers received emails, but need to know why that happened?
The state values in both Development and Test instances are identical, so I made no changes to the fix script. I did export the tickets just in case and nothing has been done in Production unless this can be fixed.
Attached is document showing screen shots of both Instances State choice list and the Fix Script.
I appreciate all the help I can get. I did have a HI ticket open and while they told me they couldn't furnish me a script, they did send me the Community link with the one I used.
Thanks!
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2019 07:41 AM
Can you try enclosing it in a function and calling it.
please put your sys_id fileter to update only one.
Also note it is gr.setWorkflow(false) not gs.
UpdateIncidentState();
function UpdateIncidentState(){
var gr = new GlideRecord('incident');
gr.addQuery('state',9);
gr.query();
while(gr.next()){
gr.setWorkflow(false);
gr.state = 7;
gr.update();
}
}
Vinod Kumar Kachineni
Community Rising Star 2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2019 07:34 AM
I made a minor adjustment and ran as a background script with no errors and it did update the one record, however still to Canceled state not to Closed state as it did in Development instance
I even tried taking the query state 9 line and while it executed, still came back as Canceled....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2019 07:41 AM
Can you try enclosing it in a function and calling it.
please put your sys_id fileter to update only one.
Also note it is gr.setWorkflow(false) not gs.
UpdateIncidentState();
function UpdateIncidentState(){
var gr = new GlideRecord('incident');
gr.addQuery('state',9);
gr.query();
while(gr.next()){
gr.setWorkflow(false);
gr.state = 7;
gr.update();
}
}
Vinod Kumar Kachineni
Community Rising Star 2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2019 08:11 AM
I ran that including the query to just do 1 record and it worked!
Let me try it again with the fix script option to make sure
If it works there, then I will mark this as Correct Answer
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2019 10:10 AM
While that worked to convert the tickets, it did not update the History or the Activity Stream with the state status like it did when I ran the original script in our Development Instance (see screen shot attached from a converted ticket in our DEV instance)
Does it need another line or so of script to get that to occur?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2019 12:10 PM
You can run the script with out the
gr.setWorkflow(false);
setWorkflow(Boolean e)
Enables or disables the running of business rules that might normally be triggered by subsequent actions. If the e parameter is set to false, an insert/update will not be audited. Auditing only happens when the parameter is set to true for a GlideRecord operation.
Vinod Kumar Kachineni
Community Rising Star 2022