Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Slow performance when getting user properties

$
0
0

Hi, guys
I'm using the PeopleManager.getMyProperties method to get the properties for the logged in user. This works fine, but it's time consuming. I really need to get a better performance, but I'm at a loss.

I assume getMyProperties retrieves ALL user properties, which is a lot. Can I make it only fetch what I actually need to reduce the amount of data being sent over the network?

Or is the getPropertiesFor method a better option performance-wise?

This is an excerpt of my JavaScript code:

SP.SOD.executeFunc('SP.Taxonomy.js', 'SP.ClientContext', function(){
	SP.SOD.executeFunc('SP.UserProfiles.js', 'SP.ClientContext', function(){
		var clientContext = new SP.ClientContext.get_current();
		var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);
		userProperties = peopleManager.getMyProperties();
		clientContext.load(userProperties);
		clientContext.executeQueryAsync(userObjectSucceded, userObjectFailed)

		function userObjectFailed(sender, args){
			console.log("GetUserObject (userObjectFailed): " + args.get_message());
		}

		function userObjectSucceded(){
			try {
				var accountName = userProperties.get_userProfileProperties()["AccountName"];
				var workEmail = userProperties.get_userProfileProperties()['WorkEmail'];
				var organization = userProperties.get_userProfileProperties()['Organization'];
				var firstName = userProperties.get_userProfileProperties()["FirstName"];
				var lastName = userProperties.get_userProfileProperties()["LastName"];
				currentUser = ({userid: accountName, email: workEmail, organization: organization, firstName: firstName, lastName: lastName});
			}
			catch (err) {
				console.log(err);
			}
		}
	});
});

Any information on the subject is appreciated. Thanks.


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>