Comments on: Add a user profile photo to a form https://servicenowguru.com/system-ui/add-user-profile-photo-to-form/ ServiceNow Consulting Scripting Administration Development Tue, 12 Mar 2024 21:23:16 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Holly https://servicenowguru.com/system-ui/add-user-profile-photo-to-form/#comment-9830 Wed, 28 Sep 2022 12:38:27 +0000 https://servicenowguru.wpengine.com/?p=12532#comment-9830 I have been using this since 2017 without issue. Upgraded to San Diego and started using the new UI. The code was running and not giving errors but my image on a catalog task was not showing up. I added a image custom field to the table and had not even put it on the form yet and this code started working again. I really don’t know why it wouldn’t show on screen before the field was added to the table and I really don’t know why adding an image field to the table allowed it to show. But it is working again and I am happy, I just have an unused field on that table.

]]>
By: Shay Faingold https://servicenowguru.com/system-ui/add-user-profile-photo-to-form/#comment-9827 Thu, 11 May 2017 12:13:46 +0000 https://servicenowguru.wpengine.com/?p=12532#comment-9827 Thank you James! just what I was looking for.

I made a small change to the macro in order to show that image on a catalog item:
var newImg = document.createElement(“img”);
newImg.src = photo_path+”?t=small”;
newImg.id = “current_live_photo”;
// photo_div.innerHTML = photo_html;
(I comment out the photo_div.innerHTML)

Shay

]]>
By: James Farrer https://servicenowguru.com/system-ui/add-user-profile-photo-to-form/#comment-9826 Tue, 09 May 2017 20:39:14 +0000 https://servicenowguru.wpengine.com/?p=12532#comment-9826 In reply to Marcel H.

The script include here gets passed the Sys ID of the user to get the photo for. To look it up based on the last user to modify the record you would need to get the User ID from the sys_updated_on field and then use that to look up the user’s Sys ID. In the global scope you can use “gs.getUser().getUserByID(‘user_name_from_sys_updated_on’).getID()” to get it. If you’re in a scoped app then you’d need to do a GlideRecord query for the user record based on the user_name field and then get the Sys ID from that record.

Once you have the Sys ID the rest of the code to get the photo is the same.

]]>
By: Marcel H https://servicenowguru.com/system-ui/add-user-profile-photo-to-form/#comment-9825 Mon, 08 May 2017 18:07:43 +0000 https://servicenowguru.wpengine.com/?p=12532#comment-9825 In reply to James Farrer.

Thanks James. Do you know off hand the best way to do this and get the photo of the person that most recently updated the record? We’d like to be able to pull the picture of the person that most recently updated the Additional comments field, whether that be the Assigned to tech or someone else.

]]>
By: James Farrer https://servicenowguru.com/system-ui/add-user-profile-photo-to-form/#comment-9824 Thu, 04 May 2017 17:20:51 +0000 https://servicenowguru.wpengine.com/?p=12532#comment-9824 In reply to Marcel H.

The value you get back as the display value for a photo field is the path to the image. If you were to put that in the HTML source of the notification then it should work pretty well. You’ll need to make sure and add the full site URL before the image path. The src attribute of the img tag would be something like src=”https://your_instance.service-now.com/${assigned_to.photo}”. You’ll also want to specify the size of the image similar to what I did in the UI macro code so it doesn’t overwhelm the message.

]]>
By: Brian Ritchey https://servicenowguru.com/system-ui/add-user-profile-photo-to-form/#comment-9823 Thu, 04 May 2017 17:04:37 +0000 https://servicenowguru.wpengine.com/?p=12532#comment-9823 This worked great! Thanks for posting this.
Brian

]]>
By: Marcel H https://servicenowguru.com/system-ui/add-user-profile-photo-to-form/#comment-9822 Thu, 04 May 2017 15:35:45 +0000 https://servicenowguru.wpengine.com/?p=12532#comment-9822 This is a great idea for a few places where service desk staff are interacting with users.

We’re trying to add that human element to another area and have struggled with it a bit. We want to add a user photo on a notification email when new comments are made on an Incident or Request record, so people can see the person making the comments, put a face to the name.

Are you aware of a simple way to do that? Any time you add something like assigned_to.photo to a notification to test, we just seem to get a sys_id.iix (e.g. bf85js8508s37rns67uuth.iix)

]]>