- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2021 04:03 PM
Hello,
I am trying to create a fix script that updates all records from a default value to 'Null'. I managed to update a record individually using the following script.
var enquirySysId='d2e94ff81b793050be465248274bcbcb,89e499d31b8df0106609cb7b1d4bcbbb'; // insert sys id here
var gr= new GlideRecord('x_mmco_streamline_enquiry');
gr.addQuery('sys_id',enquirySysId);
gr.query();
if(gr.next())
{
gr.priority ='NULL';
gr.update();
}
I would now like to use the script below to update all records but it does not look like any records are updating.
var gr= new GlideRecord('x_mmco_streamline_enquiry');
gr.query();
if(gr.next())
{
gr.setValue('priority','NULL');
gr.updateMultiple();
}
How do I get the script to update all records to 'NULL'?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2021 04:26 PM
Hi, updateMultiple() does not use query() or next() methods, as you are not iterating through a record set.
https://developer.servicenow.com/dev.do#!/reference/api/orlando/server/no-namespace/c_GlideRecordScopedAPI#r_ScopedGlideRecordUpdateMultiple?navFilter=updatemultiple
Try updating your code to mirror the SNC example
var gr = new GlideRecord('x_mmco_streamline_enquiry');
gr.setValue('priority','NULL');
gr.updateMultiple();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2021 04:26 PM
Hi, updateMultiple() does not use query() or next() methods, as you are not iterating through a record set.
https://developer.servicenow.com/dev.do#!/reference/api/orlando/server/no-namespace/c_GlideRecordScopedAPI#r_ScopedGlideRecordUpdateMultiple?navFilter=updatemultiple
Try updating your code to mirror the SNC example
var gr = new GlideRecord('x_mmco_streamline_enquiry');
gr.setValue('priority','NULL');
gr.updateMultiple();