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-06-2022 12:21 AM
Hey,
This is just a generic service interruption scree..
You have to wait for some time until your instance is restored.
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2022 12:26 AM
Every time I am running the query it leads to this page without updating the location to any single record.
Regards,
K Nandan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2022 12:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2022 08:39 PM
Hi,
Try below code
var inc = new GlideRecord('incident'); inc.addEncodedQuery('numberSTARTSWITHINC0539431');
inc.query();
while(inc.next()){
inc.location=inc.caller_id.location; inc.setWorkflow(false);
inc.autoSysFields(false);
inc.update();
If you want to update multiple records where location is empty you can try below code.
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:29 AM
Hi,
try to run for few records and verify and then run for all records
var inc = new GlideRecord('incident');
inc.addEncodedQuery('locationISEMPTY');
inc.setLimit(5); // comment this later on
inc.query();
while (inc.next()){
inc.location = inc.caller_id.location;
inc.setWorkflow(false);
inc.autoSysFields(false);
inc.update();
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader