70-489 · Question #4
You develop a SharePoint-hosted app. The app includes the following code segment: (Line numbers are included for reference only.) The app must display user profile data for the user that is logged…
The correct answer is D. var a = new SP.UserProfiles.PeopleManager(context). To display user profile properties such as PreferredName, Department, and WorkPhone in a SharePoint-hosted app using JSOM, the PeopleManager class is the correct entry point for retrieving profile data.
Question
You develop a SharePoint-hosted app. The app includes the following code segment: (Line numbers are included for reference only.) The app must display user profile data for the user that is logged in. The user profile data must include the PreferredName, Department, and WorkPhone properties. You need to ensure that the app displays the required user profile data. Which code segment should you insert at line 12?
Exhibit
Options
- Avar a = new SP.UserProfiles.UserProfile();
- Bvar a = new SP.UserProfiles.SocialFollowingManager (context);
- Cvar a = SP.UserProfiles.Profileloader.GetProfileLoader(context);
- Dvar a = new SP.UserProfiles.PeopleManager(context);
How the community answered
(40 responses)- A8% (3)
- B3% (1)
- C15% (6)
- D75% (30)
Why each option
To display user profile properties such as PreferredName, Department, and WorkPhone in a SharePoint-hosted app using JSOM, the PeopleManager class is the correct entry point for retrieving profile data.
SP.UserProfiles.UserProfile() is not a valid standalone constructor in the JSOM API and does not provide methods to directly retrieve named profile properties.
SP.UserProfiles.SocialFollowingManager is scoped to managing social follow relationships (people, documents, sites) and has no methods for reading profile property values.
SP.UserProfiles.ProfileLoader.GetProfileLoader(context) retrieves a ProfileLoader object for loading the current user's profile container, but it does not expose individual properties like Department or WorkPhone directly.
SP.UserProfiles.PeopleManager(context) is the correct class for accessing user profile properties in the SharePoint JavaScript client object model. It exposes methods such as GetMyProperties() and GetPropertiesFor() that return a PersonProperties object containing named profile fields like PreferredName, Department, and WorkPhone. This is the standard and supported API for reading user profile data in SharePoint-hosted apps.
Concept tested: SharePoint JSOM user profile retrieval using PeopleManager
Source: https://learn.microsoft.com/en-us/sharepoint/dev/general-development/work-with-user-profiles-in-sharepoint
Topics
Community Discussion
No community discussion yet for this question.
