- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2023 10:46 AM
Hi,
How can I delete the image from the 'photo' field on the sys_user table for all users in the system using a Fix script?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2023 11:39 AM
I can see records are going to the sys_attachment table, if you delete from there it would be automatically remove from users table
here is the script, before executing the script please try it for single record:
var gr = new GlideRecord("sys_attachment");
gr.addEncodedQuery("table_name=ZZ_YYsys_user");
gr.setLimit(1); //remove this for all the records
gr.query();
while(gr.next()){
gr.deleteRecord();
}
I hope you will get an idea!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2023 11:25 AM
Please try this -
function deletePhotoField(user) {
var photo = user.getPhoto();
if (photo && photo.exists()) {
photo.deleteRecord();
}
}
var users = new GlideRecord('sys_user');
users.query();
while (users.next()) {
deletePhotoField(users);
}
Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Regards,
Tushar