gr.update() not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2019 02:48 AM
Hi,
gr = new GlideRecord('incident');
gr.addQuery('stateNOT IN6,7,8');
gr.query();
while (gr.next()) {
gr.description = gr.description + '.';
gr.update();
}
The above is a small code i am writing to update all open incidents(anything except Resolved, Closed, Cancelled) state with a " . " in the description
When i run this query in the scripts background it is randomly updating only few tickets and it is not updating all tickets.
I am not sure what wrong i am doing here. What change should i make in this query to update all the incidents.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2019 03:01 AM
What do you need to set in your description field......? Your code will set a dot in description field of all open/active incidents having state not one of resolved/closed/canceled.
Regards,
Ajay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2019 03:02 AM
Yes that is what i want to see. a dot in the description field of all tickets

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2019 03:05 AM
I tried the code in my dev instance it's working fine.
You have to write the code in background script.
Regards,
Ajay

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2019 03:06 AM
Hi,
I just ran your latest code and could see dot appended for the description of all incidents.
Don't you see dot in the description field? Kindly note its a description where you are adding . and not in short_description.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2019 03:06 AM
Run this code in background and see if it is showing description with the dot.
var gr = new GlideRecord('incident');
gr.addEncodedQuery("active=true^stateNOT IN6,7,8");
gr.query();
while (gr.next()) {
gr.description = gr.description + '.';
gs.print("Description is "+gr.description);
gr.update();
}