Update location field on incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2022 08:26 PM
Hi All
on incidents list view location is empty for many incidents. So i tried to set it as caller's location. For that I have written a background script like below to update initially a single record-
var inc = new GlideRecord('incident');
inc.addEncodedQuery('numberSTARTSWITHINC0539431');
inc.query();
while(inc.next){
inc.location=inc.caller_id.location;
inc.update();
inc.setWorkflow(false);
inc.autoSysFields(false);
}
But the request gets timed out and instance became unavailable after few minutes. So can anyone helpme how do I update location field in bulk for incidents.
Regards,
K Nandan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2022 08:37 PM
Hi Evan,
Should set setWorkflow() and autoSysFields() before update()
var inc = new GlideRecord('incident');
inc.addQuery('number', 'INC0539431');
inc.query();
if (inc.next()){
inc.location=inc.caller_id.location;
inc.setWorkflow(false);
inc.autoSysFields(false);
inc.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2022 08:38 PM
It's also "next()".

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2022 08:44 PM
To update all incidents with location not set, use the following script.
var inc = new GlideRecord('incident');
inc.addEncodedQuery('locationISEMPTY');
inc.query();
while (inc.next()){
inc.location=inc.caller_id.location;
inc.setWorkflow(false);
inc.autoSysFields(false);
inc.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2022 12:08 AM