How to make field empty- It's an Emergency please

chanikya
Kilo Sage

A roundly 592 records of Emp co-ordinator field got Default user name ,

How can i make field empty at a time to all records.

My script is not working:

var grd=new GlideRecord('sys_user');

grd.addEncodedQuery('u_emp_no=NULL');

//grd.addEn('u_emp_no=NULL');

grd.query();

while(grd.next())

{

current.u_emp_manager= '';

}

find_real_file.png

1 ACCEPTED SOLUTION

Prateek kumar
Mega Sage

Chanikya


Please navigate to-- system definition>>Scripts- Background from the filter navigator and run this script


Script:


var str = "employee_number=NULL";


var gr = new GlideRecord('sys_user');


gr.addEncodedQuery(str);


gr.query();


while(gr.next()){


gr.u_emp_manager = '' ;


gr1.setWorkflow(false);


gr1.autoSysFields(false);


gr.update();


}



Please mark my response as correct and helpful if it helped solved your question.
-Thanks

View solution in original post

10 REPLIES 10

Prateek kumar
Mega Sage

Hello chanikya


You can run a background script and make that field empty.



Please mark my response as correct and helpful if it helped solved your question.
-Thanks

How ''Emp Coordinator''   field should be empty when ''Emp no'' field   no value




Can you please help me on this thread


sachin_namjoshi
Kilo Patron
Kilo Patron

Please run below fix script



var grd=new GlideRecord('sys_user');




grd.addEncodedQuery('managerISNOTEMPTY^user_name=alex.wang');




//grd.addEn('u_emp_no=NULL');




grd.query();




while(grd.next())




{




grd.manager = "";


grd.setWorkflow(false);


grd.update();




}



Regards,


Sachin


jarodm
Mega Guru

You're just missing a `current.update();` inside your while loop.



Alternatively, you could look into `current.updateMultiple();`