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

Script used to delete some specific users from snow

geet
Tera Guru

Greetings All,

I have written a script to delete those users whose Email, User ID, Ldap-Server is blank. Please let me know if it is ok.

var encodedQuery="emailISEMPTY^user_nameISEMPTY^ldap_serverISEMPTY";   // semicolon added

var gr = new GlideRecord("sys_user");     //error here " needed to be closed

gr.addEncodedQuery(encodedQuery);

gr.deleteMultiple();

1 ACCEPTED SOLUTION

If you do go with deactivating, rather than deleting, I'd do it through the UI:


Capture.PNG


Capture.PNG


View solution in original post

22 REPLIES 22

So did these manually added users create any records during that time? I mean did they access the system and work.


I am not sure. might be Yes as SNOW came to us in Jan 2015 and got integrated with AD in april 2015


Oh. Then if you delete the users and open any record that these users had created there will be not detail who created it.



I hope you understand. I suggest deactivate these users.



Please mark the response helpful or correct if you feel so.


Ok surely i will consider your point but what if i use the following in my script:



autoSysFields(false);   // Do not update sys_updated_by, sys_updated_on, sys_mod_count, sys_created_by, and sys_created_on


All that does is make sure you don't strap your name as the last updated by to the record you're deleting.   Wouldn't matter what the sys_updated/created values were after a delete anyway.