Remove values in a field

MStritt
Tera Guru

I need to bulk remove values in a field that I populated using an import set. Is there sample code to run a script (fixed script) to remove all values in a field called u_securty_contact? On the customer_account table.

1 ACCEPTED SOLUTION

ServiceNowVS
Tera Expert

You can use something like

 var gr = new GlideRecord('customer_account');
gr.addQuery(<query to identify you created via import set>);
gr.addQuery('u_security_contactISNOTEMPTY');
gr.query();
  while (gr.next()) {
 
     gr.u_security_contact = '';
gr.update();
        }

View solution in original post

4 REPLIES 4

Andrew_TND
Mega Sage
Mega Sage

Unless you have a common identifier, e.g. field starts with "UPLOAD" you could use an addQuery(), find the values and clear them, otherwise a quick and dirty way would be just to find all records updated at that septic time and remove the values in bulk via the list editor... Obviously the longer you leave it the harder it will be to track down.

Please mark as helpful or if it resolved the issue CORRECT!

ServiceNowVS
Tera Expert

You can use something like

 var gr = new GlideRecord('customer_account');
gr.addQuery(<query to identify you created via import set>);
gr.addQuery('u_security_contactISNOTEMPTY');
gr.query();
  while (gr.next()) {
 
     gr.u_security_contact = '';
gr.update();
        }

Hi!

 

I'm getting a parsing error on line 2.

MStritt_0-1688075634824.png

 

 

 

That was an example i put up . You need to add a query to identify records which are created via your import set. Is there any identifier?