nerdexam
Microsoft

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.

Design and develop advanced Microsoft SharePoint 2013 solutions

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

70-489 question #4 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)
  • A
    8% (3)
  • B
    3% (1)
  • C
    15% (6)
  • D
    75% (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.

Avar a = new SP.UserProfiles.UserProfile();

SP.UserProfiles.UserProfile() is not a valid standalone constructor in the JSOM API and does not provide methods to directly retrieve named profile properties.

Bvar a = new SP.UserProfiles.SocialFollowingManager (context);

SP.UserProfiles.SocialFollowingManager is scoped to managing social follow relationships (people, documents, sites) and has no methods for reading profile property values.

Cvar a = SP.UserProfiles.Profileloader.GetProfileLoader(context);

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.

Dvar a = new SP.UserProfiles.PeopleManager(context);Correct

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

#user profiles#PeopleManager#CSOM#SharePoint-hosted app

Community Discussion

No community discussion yet for this question.

Full 70-489 Practice