i am having little problem in getting Sharepoint Userid (GUID) in SP App 2013. so far i am getting Sharepoint user's Email address and his Full name using userProfile class of Sharepoint (SP.UserProfile.js).
i needed to get Unique id of the user which we say GUID.. i used below code for that , but everytime i get random so called Guid of the same User.(ehich is definitely not unique id of user). How can i get sharepoint's user id that is unique on every login.
Please Help!
Thanks
Here is my code snippet
var targetUser;
var userProps;
var contxt_web = null;
var clientContext = new SP.ClientContext.get_current();
/** Get id of Current SP User*/
contxt_web = clientContext.get_web();
clientContext.load(contxt_web);
/***/
peopleManager = new SP.UserProfiles.PeopleManager(clientContext);
userProps = peopleManager.getMyProperties(targetUser);
clientContext.load(userProps);
clientContext.executeQueryAsync(onRequestSuccess, onRequestFail);
}
function onRequestSuccess() {
var messageText = "Name : " + userProps.get_displayName()
+ " Sharepoint-ID : " + contxt_web.get_id()
+ " Email : " + userProps.get_email();
}
Try using userprops.get_userId ,it may works..