Last active
October 7, 2016 14:34
-
-
Save durgesh97025/ec66950541581e5b518c6a87794ffa60 to your computer and use it in GitHub Desktop.
Get User Profile Properties of Current User and Specified User
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function GetUserProfileProperties() { | |
var userProfileProperties; | |
var peopleManager = new SP.UserProfiles.PeopleManager(rClientContext); | |
userProfileProperties = peopleManager.getMyProperties(); | |
rClientContext.load(userProfileProperties); | |
rClientContext.executeQueryAsync(onRequestSuccess, onRequestFail); | |
function onRequestSuccess() { | |
//https://unicef-my.sharepoint.com/_layouts/15/EditProfile.aspx?UserSettingsProvider=dfb95e82-8132-404b-b693-25418fdac9b6 | |
//The list of properties | |
var arrayOfProp = userProfileProperties.get_userProfileProperties() | |
$.GetFieldControl("RequestorFirstName").val(arrayOfProp["FirstName"]); | |
$.GetFieldControl("RequestorLastName").val(arrayOfProp["LastName"]); | |
$.GetFieldControl("RequestorFunctionalTitle").val(arrayOfProp["SPS-JobTitle"]); | |
} | |
function onRequestFail(sender, args) { alert( args.get_message());} | |
} | |
function SetFieldsValueForUser() { | |
var d = $.Deferred(); | |
DialogMessage("Loading Current User Properties"); | |
var userProfileProperties; | |
var peopleManager = new SP.UserProfiles.PeopleManager(rClientContext); | |
log("G_AccountName: " + G_AccountName); | |
userProfileProperties = peopleManager.getPropertiesFor(G_AccountName);//G_AccountName = i:0#.f|membership|XX@XX.org | |
rClientContext.load(userProfileProperties); | |
rClientContext.executeQueryAsync(onRequestSuccess, onRequestFail); | |
function onRequestSuccess() { | |
//https://unicef-my.sharepoint.com/_layouts/15/EditProfile.aspx?UserSettingsProvider=dfb95e82-8132-404b-b693-25418fdac9b6 | |
//The list of properties | |
DialogMessage("User Values Received...") | |
var arrayOfProp = userProfileProperties.get_userProfileProperties() | |
$.GetFieldControl("RequestorFirstName").val(arrayOfProp["FirstName"]); | |
$.GetFieldControl("RequestorLastName").val(arrayOfProp["LastName"]); | |
$.GetFieldControl("RequestorFunctionalTitle").val(arrayOfProp["functionalTitle"]); | |
$.GetFieldControl("RequestorDutyStation").val(arrayOfProp["unicefDutyStationName"]); | |
log("user Properties Feteched and displayed"); | |
d.resolve(); | |
} | |
function onRequestFail(sender, args) { | |
log(args.get_message()); | |
d.reject(); | |
} | |
return d.promise(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment