
- 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 06:02 AM
Hi Terrieb
Definitely looks odd
If you add the line
gs.setWorkflow(false);
just before your gr.update();
This enables you to ignore all the business rules etc that fire notifications when you do an update.
also if you add to your query block after your state query
gr.addQuery('sys_id','4f899491db663200cfdefda41d961975'); // where sys id is id of 1 of your records you limit it to 1 record for test
Take your script and run it in background on your subprod and see what it does.
then comment out your query line that looks for 9 and run again.
Logging will probably be useful.
Just have to step through what output you are getting and try to isolate your issue. Though looking at the script it doesn't look like a code issue
Regards

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2019 06:25 AM
I made the changes as you suggested but before I run, can you verify its correct
gr.addQuery('state',9);
gr.addQuery('sys_id','ef6f9c154f0d3700a76597dd0210c7dc')
gr.query();
while(gr.next()){
gr.state = 7;
gs.setWorkflow(false);
gr.update();
}
If it is, I will run again and update this
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2019 06:19 AM
Hi,
Can you try the same snippet in background script & see the results. If it works well, then enable the Flush cache checkbox in the Fix Script & trying running it again.
Thanks,
Jaspal Singh
Hit Helpful or Correct on the impact of response.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2019 07:29 AM
Did the background script and got this message:
[0:00:00.017] Script completed in scope global: script
Script execution history and recovery available here
Evaluator: org.mozilla.javascript.EcmaError: "gr" is not defined. Caused by error in script at line 1 ==> 1: gr.addQuery('state',9); 2: 3: 4: