Quantcast
Viewing all articles
Browse latest Browse all 6517

Updated Wiki: $().SPServices.SPGetCurrentUser

Function

$().SPServices.SPGetCurrentUser

Certification

Image may be NSFW.
Clik here to view.
Certified for SharePoint 2007
Image may be NSFW.
Clik here to view.
Certified for SharePoint 2010
*

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).

Syntax

$().SPServices.SPGetCurrentUser({  webURL: "",		// Added in 2013.01
fieldName: "Name",  fieldNames: {},      // Added in v0.7.2 to allow multiple columns
debug: false });

webURL
URL 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 theField Internal Name column below). You can specify any of theField 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 theuserdisp.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
AccountNameImage may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
NameTitleImage may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
Work e-mailEMailImage may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
About meNotesImage may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
PicturePictureImage may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
DepartmentDepartmentImage may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
Job TitleJobTitleImage may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
SIP AddressSipAddressImage may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
First nameFirstName Image may be NSFW.
Clik here to view.
Last NameLastName Image may be NSFW.
Clik here to view.
Work phoneWorkPhone Image may be NSFW.
Clik here to view.
OfficeOffice Image may be NSFW.
Clik here to view.
User nameUserName Image may be NSFW.
Clik here to view.
Web siteWebSite Image may be NSFW.
Clik here to view.
ResponsibilitiesSPResponsibility Image may be NSFW.
Clik here to view.

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.

Examples

var thisUserAccount = $().SPServices.SPGetCurrentUser({
	fieldName: "Name",
	debug: false
}); 
var thisUserName = $().SPServices.SPGetCurrentUser({
	fieldName: "Title",
	debug: false
});
var thisUserID = $().SPServices.SPGetCurrentUser({
	fieldName: "ID",
	debug: false
});

 

var thisUsersValues = $().SPServices.SPGetCurrentUser({
	fieldNames: ["ID", "Name", "SIP Address"],
	debug: false
});
 

* Attested by Geoff Varosky


Viewing all articles
Browse latest Browse all 6517

Trending Articles



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