Friday, 20 September 2013

SharePoint SP Services Get User Profile Properties

'GetUserData':function(loginName){
        $().SPServices({
            operation: "GetUserProfileByName",
            AccountName: loginName, // replace adLogin with your string expression
            completefunc:function(data,status) {
                var profile = {};
                $(data.responseText).find("PropertyData").each(function(idx, val) {
                    var $val = $(val);
                    var name = $val.find("Name").text();
                    var value = $val.find("Value").text();
                    profile[name] = value;
                });
                ////////////debugger;
                // At this point the profile object has all profile properties:
                User.id = _spPageContextInfo.userId;
                User.title = profile.Title;
                User.userCountry = profile.UCBCountry;
                User.loginName = profile.AccountName;

            }
        });
    }

Share This!


No comments:

Post a Comment

Translate

Total Pageviews

Powered By Blogger · Designed By Seo Blogger Templates