Profile Photos

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 09:01 PM
Can someone help me out by explaining the differences between the photo field on sys_user/sys_attachment and the "Live Profile" picture that users can manage themselves through Service Portal?
Where is the "Live Profile" photo stored? Is there any existing (in-built) solution to just have them all match?
I currently have one user that has 3 different photos. One when viewing sys_user record, another in Service Portal when admins view him, and a third image in Service Portal when non-admins view him. It's just weird.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2018 11:22 AM
stevejarman, did you ever find a way to sync your photo's? We have tested importing photo's from AD on our Dev environment but found that the live profile photo takes precedence over the sys_user photo. If you found a way to sync the photo's it would be really handy to try and implement with our import. Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2018 11:15 AM
Little late to the party here, but I'm in the same boat. I'm actually working on a Record Producer that takes either the picture (the OOB picture picker off the Portal) and a set of fields, and that will kick off workflow to sync it all with Active Directory via PowerShell.
Really neat concept, and I have everything working, except the picture. Looking at the event logs (you can see attachment upload and delete events), I also see that 2 versions of the pictures end up in the sys_attachment table, under table ZZ_YYlive_profile, and sys_attachment.
My idea for a closer OOB solution, is to create a Business rule that On Insert into the sys_attachment table, it deletes the existing sys_user attachment, and copies that one.
I'll upload my code once I have a version working!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2018 08:45 AM
Creating an On Insert BR on the sys_attachment table, with conditions Table name is "ZZ_YYlive_profile", and the below script, should do the trick to copy the image from the live profile to the user profile.
(function executeRule(current, previous /*null when async*/) {
try{
var user = current.sys_created_by;
var user_id = '', userTbl = 'sys_user';
var attach = new GlideSysAttachment();
var userGR = new GlideRecord(userTbl);
if(userGR.get('user_name',user)){
user_id = userGR.sys_id;
//Find and Delete all Attachments on Record
attach.deleteAll(userGR);
//Delete leftover images
var agr = attach.getAllAttachments("ZZ_YYsys_user",user_id);
while(agr.next()){
attach.deleteAttachment(agr.getValue("sys_id"));
}
//copy over new attachment
//this updates the image field, but doesn't visibly show as an attachment
attach.copy('live_profile',current.table_sys_id,userTbl,user_id);
//note: file name has to match field name - in this case it is fine 'photo' to 'photo'
userGR.update(); //actually important because it refreshes the image field
//Optional, to upload it as an actual attachment use this ECC Queue method
//https://community.servicenow.com/community?id=community_question&sys_id=0ed197addbdcdbc01dcaf3231f96190a
gs.log("Successfully copied Profile picture for "+user);
}else{
gs.log("Failed to find user profile to copy picture. "+user);
}
}catch(err){
gs.log("Error copying "+user+"'s Profile picture - "+err.message);
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2018 03:22 PM
Is there any way to do this in the reverse? We are updating the sys_user table with photos from Active Directory, and that is working fine, but we want to sync it to Live Profile (reverse I believe) - have you been able to accomplish that?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2020 11:06 PM
Extremely late reply, but better late than never. You could easily copy from the sys_user table picture to the live profile. with very similar code to the above.
Creating an On Insert BR on the sys_attachment table, with conditions Table name is "ZZ_YYsys_user". Then you can just remove the parts of code in my script for deleting, and just switch the sys_user and live_profile references around to copy from the user table to the profile table.