- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2022 10:52 PM
hi
I want to delete empty records from user table. How to achieve this by using script?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2022 11:06 PM
Hi @SK36 ,
I'm considering here username as empty. You may have different field. apply query according to that.
var gr = new GlideRecord('sys_user');
gr.addEncodedQuery('user_nameISEMPTY'); // user_nameISEMPTY if user id field is empty and people id filed is empty
gr.query();
while (gr.next()) {
gr.deleteMultiple();
}
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2022 11:02 PM
how do you mean by empty records?
what script did you start with?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2022 01:05 AM
Unfortunately you didn't share answers to my questions.
Glad that you got the script.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2022 11:06 PM
Hi @SK36 ,
I'm considering here username as empty. You may have different field. apply query according to that.
var gr = new GlideRecord('sys_user');
gr.addEncodedQuery('user_nameISEMPTY'); // user_nameISEMPTY if user id field is empty and people id filed is empty
gr.query();
while (gr.next()) {
gr.deleteMultiple();
}
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2022 11:10 PM
Hi, is this fix script or background script?