mercredi 4 mars 2015

this.get_context is not a function when call getMyProperties

When I call the code below:

script type="text/javascript" src="/_layouts/15/SP.js" /script

script type="text/javascript" src="/_layouts/15/SP.UserProfiles.js" /script

script type="text/javascript"

var personProperties; function getUserProperties() {

// Get the current client context and PeopleManager instance.
var clientContext = new SP.ClientContext.get_current();
var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);

// Get user properties for the target user.
// To get the PersonProperties object for the current user, use the
// getMyProperties method.
personProperties = peopleManager.getMyProperties();

// Load the PersonProperties object and send the request.
clientContext.executeQueryAsync(onRequestSuccess, onRequestFail);

// This function runs if the executeQueryAsync call succeeds.
function onRequestSuccess() {

// Get a property directly from the PersonProperties object.
var messageText = " \"DisplayName\" property is "
+ personProperties.get_displayName();

// Get a property from the UserProfileProperties property.
messageText += "<br />\"Department\" property is "
+ personProperties.get_userProfileProperties()['Department'];

// This function runs if the executeQueryAsync call fails.
function onRequestFail(sender, args) {
alert("Error: " + args.get_message());

(function () {

$(function () { SP.SOD.executeOrDelayUntilScriptLoaded(getUserProperties, 'SP.UserProfiles.js'); }); })(); the getMyProperties() rise an error like: undefined is not a function; can someone help me? It seem's to be internal on SP.UserProfile.js

0 commentaires:

Enregistrer un commentaire