Question

I'm currently working with the SharePoint Framework Extensions that are currently in developer preview – specifically Application Customizers. How can I lookup user profile properties for the current user?

Was it helpful?

Solution

You can use PnP JS to get the entire user profile properties as shown below :

pnp.sp.profiles.myProperties.get().then(function(result) {
var userProperties = result.UserProfileProperties;
var userPropertyValues = "";
userProperties.forEach(function(property) {
userPropertyValues += property.Key + " - " + property.Value + "<br/>";
});
document.getElementById("spUserProfileProperties").innerHTML = userPropertyValues;
}).catch(function(error) {
 console.log("Error: " + error);
});

get User Profile properties using SPFx and PnP JS

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top