SPServices.SPGetCurrentUser returns null when [Manager] is the required field

Oct 19, 2012 at 9:29 PM

Context: SharePoint Online

Manager Property is set and accessible (InfoPath gets it)

var userManager = $().SPServices.SPGetCurrentUser({fieldName: "Manager"});

Issue: userManager==null

Oct 19, 2012 at 10:35 PM
Edited Oct 19, 2012 at 10:35 PM

The documentation on GetCurrentUser makes no mention that Manager is a field that can be retrieved by the function.

Oct 20, 2012 at 10:15 PM

I see it.

I was debugging and thinking.....

There's a way to resolve it (it should be updated to get an array of properties):

function GetProfilePropertyValue(userId, propertyName) {
    var retVal;

    $().SPServices({
        operation: 'GetUserProfileByName',
        AccountName: userId,
        async: false,
        completefunc: function (xData, Status) {
            var properties = xData.responseXML.getElementsByTagName('PropertyData');

            var propertyValues = new Array();
            for (var i = 0; i < properties.length; i++) {
                var propName = properties[i].getElementsByTagName('Name')[0].childNodes[0].nodeValue;
                propertyValues[propName] = properties[i].getElementsByTagName('Value');

                var oValueNode = properties[i].getElementsByTagName('Value');
                if (oValueNode.length > 0) {
                    propertyValues[propName] = oValueNode[0].childNodes[0].nodeValue;
                } else {
                    propertyValues[propName] = '';
                }
            }
            retVal = propertyValues[propertyName];
        }
    });
    return retVal;

}

It works :)