Function

Certification

Functionality

This utility function, which is also publicly available, returns information about the current user.

How It Works

The SPGetCurrentUser function does an AJAX call to grab
/_layouts/userdisp.aspx?Force=True and "scrapes" the values from the page based on the internal field name (aka StaticName).

Note: There is a bug in the versions 2013.01, 2013.02, and 2014.01 where only the relative path ("/") is returned from $().SPServices.SPGetCurrentSite
rather than the full path ("http://servername/sitename"). This causes problems in the root site for $().SPServices.SPGetCurrentUser.

Syntax

webURLURL of the target Site Collection. If not specified, the current Web is used.

fieldName
You can specify which value from userdisp.aspx you'd like returned with this option. The default is the user's account (Name in the
Field Internal Name column below). You can specify any of the
Field Internal Names for option
fieldName. The fields listed below are the default out-of-the-box fields. If you’ve got custom fields which are exposed on the
userdisp.aspx page, then you should be able to retrieve them with this function as well.

Note that, as of
v0.6.1, you can also request the ID of the user by specifying fieldName: "ID".

Field Name

Field Internal Name

WSS

MOSS

Account

Name

Name

Title

Work e-mail

EMail

About me

Notes

Picture

Picture

Department

Department

Job Title

JobTitle

SIP Address

SipAddress

First name

FirstName

Last Name

LastName

Work phone

WorkPhone

Office

Office

User name

UserName

Web site

WebSite

Responsibilities

SPResponsibility

fieldNames
Added in v0.7.2 to allow requesting multiple column values. The column names can be passed in as an array, such as ["ID", "Last Name"]

debug
Setting debug: true indicates that you would like to receive messages if anything obvious is wrong with the function call, like specifying a value which doesn't exist. I call this
debug mode.

For those that are asking how to get multiple column values. Just use:var thisUsersValues = $().SPServices.SPGetCurrentUser({ fieldNames: ["Title", "EMail", "Office"], debug: false});alert(thisUsersValues.EMail);or alert(thisUsersValues.Titlel);

I am finding that this is not gettign the loginName of the user, if used at a subsite level. At the root level I get the loginName, at a subsite level I get nothing (empty loginName). I am using v0.7.2.

A similar request to Zullu, is to be able to get and display profile info on a Master Page as a result of UPS sync with custom AD properties var company = $().SPServices.SPGetCurrentUser({ fieldName: "Company", debug: true });

Although this is populated in user's profile the above variable is null

Couple of questions:#1. How do we get the property "Office Location". I see that it has an internal name as [SPS-Location] in my User Profile.#2. The above list of field names has ONLY 15 of them listed. Does it mean I cannot retrieve the others. #3. I was wondering if the call $().SPServices.SPGetCurrentUser() pulls data directly from Active Directory or does it looks into the SP User Profiles? I am using SP 2010 Enterprise.