- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2019 11:00 AM
On a choice type field, record by record update (to blank) works. But updateMultiple doesn't blank outs the value but retains the previous value.
Ex:
var gr = new GlideRecord('table');
gr.addQuery('sys_id', 'IN', 'sysId1,sysId2');
gr.setValue('choice_field', '');
gr.updateMultiple();
doesn't work
But the following works fine
var gr = new GlideRecord('table');
gr.addQuery('sys_id', 'IN', 'sysId1,sysId2');
gr.query();
while(gr.next()){
gr.setValue('choice_field','');
gr.update();
}
Do I miss anything here?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2019 12:40 AM
Hi Alok,
Thanks for the reply. For updateMultiple - gr.query() maybe optional.
I tried the below and it worked:
var gr = new GlideRecord('table');
gr.addQuery('sys_id', 'IN', 'sysId1,sysId2');
gr.setValue('choice_field', 'NULL'); - empty string doens't nulfiy the choice field
gr.updateMultiple();
Looks like record by record and update multiple works differently if we try to blank out the choice field by empty string.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2019 11:03 AM
Hi Muthu,
You missed to add
gr.query();
your updated script would be:
var gr = new GlideRecord('table');
gr.addQuery('sys_id', 'IN', 'sysId1,sysId2');
gr.query();
gr.setValue('choice_field', '');
gr.updateMultiple();
Also you can refer to the below link for more details on updatemultiple() function
https://developer.servicenow.com/app.do#!/api_doc?v=madrid&id=r_GlideRecord-updateMultiple
Please mark my answer correct/helpful based on the impact.
Regards,
Alok
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2019 12:40 AM
Hi Alok,
Thanks for the reply. For updateMultiple - gr.query() maybe optional.
I tried the below and it worked:
var gr = new GlideRecord('table');
gr.addQuery('sys_id', 'IN', 'sysId1,sysId2');
gr.setValue('choice_field', 'NULL'); - empty string doens't nulfiy the choice field
gr.updateMultiple();
Looks like record by record and update multiple works differently if we try to blank out the choice field by empty string.