From 0e67e904f5f7cf927aabb027f0bd6e889d14fa2a Mon Sep 17 00:00:00 2001 From: brenduh Date: Tue, 30 Sep 2025 16:25:14 -0500 Subject: [PATCH 1/5] Create Get Profile Picture --- .../Script Includes/Get Profile Picture | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Server-Side Components/Script Includes/Get Profile Picture diff --git a/Server-Side Components/Script Includes/Get Profile Picture b/Server-Side Components/Script Includes/Get Profile Picture new file mode 100644 index 0000000000..32ad6cd0b2 --- /dev/null +++ b/Server-Side Components/Script Includes/Get Profile Picture @@ -0,0 +1,44 @@ +var cf_LiveProfile = Class.create(); +cf_LiveProfile.prototype = Object.extendsObject(AbstractAjaxProcessor, { + /* + * Retrieves the user photo from the Live Profile, if possible, otherwise + * gets the photo from the user record if possible. + * + * Returns the path to the photo or an empty string + */ + getPhoto: function(){ + // Get the Sys ID of the user that we're retrieving the photo for + var user_id = this.getParameter('sysparm_user_id'); + gs.log("getPhoto called for: " + user_id, "cf_LiveProfile"); + var photo_path; + + // Query for the live profile record + var live_profile_gr = new GlideRecord('live_profile'); + live_profile_gr.addQuery('document', user_id); + live_profile_gr.query(); + if(live_profile_gr.next()) { + if(live_profile_gr.photo.getDisplayValue()){ + photo_path = live_profile_gr.photo.getDisplayValue(); + gs.log("Retrieved photo from live profile: " + photo_path, "cf_LiveProfile"); + + } + } + // Check to see if we have a photo from the profile + if(!photo_path){ + // No profile photo found, query for the user photo + var user_gr = new GlideRecord('sys_user'); + user_gr.addQuery('sys_id', user_id); + user_gr.query(); + if(user_gr.next()) { + photo_path = user_gr.photo.getDisplayValue(); + gs.log("Retrieved photo from user record: " + photo_path, "cf_LiveProfile"); + } else { + photo_path = ''; + gs.log("No photo found", "cf_LiveProfile"); + } + } + return photo_path; + }, + + type: 'cf_LiveProfile' +}); From e04fdcafe5a03cbe8cc8526550c889e4439762d0 Mon Sep 17 00:00:00 2001 From: brenduh Date: Tue, 30 Sep 2025 16:31:09 -0500 Subject: [PATCH 2/5] Rename Get Profile Picture to Get Profile Picture.js --- .../{Get Profile Picture => Get Profile Picture.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Server-Side Components/Script Includes/{Get Profile Picture => Get Profile Picture.js} (100%) diff --git a/Server-Side Components/Script Includes/Get Profile Picture b/Server-Side Components/Script Includes/Get Profile Picture.js similarity index 100% rename from Server-Side Components/Script Includes/Get Profile Picture rename to Server-Side Components/Script Includes/Get Profile Picture.js From afe440ee915ade9fc2a8daf8a4fd98bec6bd8009 Mon Sep 17 00:00:00 2001 From: brenduh Date: Tue, 30 Sep 2025 16:35:14 -0500 Subject: [PATCH 3/5] Rename Server-Side Components/Script Includes/Get Profile Picture.js to Server-Side Components/Script Includes/Get Profile Picture/GetProfilePicture.js --- .../GetProfilePicture.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Server-Side Components/Script Includes/{Get Profile Picture.js => Get Profile Picture/GetProfilePicture.js} (100%) diff --git a/Server-Side Components/Script Includes/Get Profile Picture.js b/Server-Side Components/Script Includes/Get Profile Picture/GetProfilePicture.js similarity index 100% rename from Server-Side Components/Script Includes/Get Profile Picture.js rename to Server-Side Components/Script Includes/Get Profile Picture/GetProfilePicture.js From 639a9331b2dee23d3bfd997ba0bbc10295cd8c27 Mon Sep 17 00:00:00 2001 From: brenduh Date: Tue, 30 Sep 2025 16:35:59 -0500 Subject: [PATCH 4/5] Rename GetProfilePicture.js to getProfilePicture.js --- .../{GetProfilePicture.js => getProfilePicture.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Server-Side Components/Script Includes/Get Profile Picture/{GetProfilePicture.js => getProfilePicture.js} (100%) diff --git a/Server-Side Components/Script Includes/Get Profile Picture/GetProfilePicture.js b/Server-Side Components/Script Includes/Get Profile Picture/getProfilePicture.js similarity index 100% rename from Server-Side Components/Script Includes/Get Profile Picture/GetProfilePicture.js rename to Server-Side Components/Script Includes/Get Profile Picture/getProfilePicture.js From af6d7039b2b6e22f74479e3193e159f1a0f8f8e7 Mon Sep 17 00:00:00 2001 From: brenduh Date: Tue, 30 Sep 2025 16:36:44 -0500 Subject: [PATCH 5/5] Create README.md --- .../Script Includes/Get Profile Picture/README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Server-Side Components/Script Includes/Get Profile Picture/README.md diff --git a/Server-Side Components/Script Includes/Get Profile Picture/README.md b/Server-Side Components/Script Includes/Get Profile Picture/README.md new file mode 100644 index 0000000000..25aa75ada3 --- /dev/null +++ b/Server-Side Components/Script Includes/Get Profile Picture/README.md @@ -0,0 +1,2 @@ +Retrieves the user photo from the Live Profile, if possible, otherwise gets the photo from the user record if possible. +Returns the path to the photo or an empty string