The CreatorCon Call for Content is officially open! Get started here.

Update location field on incident

Evan2
Kilo Guru

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

10 REPLIES 10

Hitoshi Ozawa
Giga Sage
Giga Sage

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();
}

It's also "next()".

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();
}

Hi Hitoshi,

 

After running this I am getting the below screen. Can we please limit the records for last 2 months only.

 

find_real_file.png