Quantcast
Channel: jQuery Library for SharePoint Web Services
Viewing all articles
Browse latest Browse all 6517

Updated Wiki: $().SPServices

$
0
0

Function

$().SPServices

Certification

Certified for SharePoint 2007Works with Caveats with SharePoint 2010
See individual Web Services pages for certification specifics.

Notes

As of v0.7.2, the core $().SPServices() function allows for simple caching of the XML results using jQuery promises in a similar manner to that outlined in Scot Hillier's excellent post Utilizing Promises in SharePoint 2013 Apps. See the Caching page for more details.

Supported Web Services

The table below shows the Web Services for which we have implemented at least one operation (or have operations coming in planned releases) with a link to more detailed documentation, indicators for whether the Web Service is available in WSS 3.0 and/or MOSS, and links to the MSDN documentation pages. Note that there are some general syntax instructions below the table.

 SharePoint 2007 SharePoint 2010
Web ServiceWSS 3.0MOSSMSDN DocumentationFoundationSP2010
Alertschkmrkchkmrk[2]Alerts Web Servicechkmrk[2]chkmrk[2]
Authenticationchkmrk[2]chkmrk[2]Authentication Web Servicechkmrk[2]chkmrk[2]
Copychkmrk[2]chkmrk[2]Copy Web Servicechkmrk[2]chkmrk[2]
Formschkmrk[2]chkmrk[2]Forms Web Servicechkmrk[2]chkmrk[2]
Listschkmrk[2]chkmrk[2]Lists Web Servicechkmrk[2]chkmrk[2]
Meetingschkmrk[2]chkmrk[2]Meetings Web Servicechkmrk[2]chkmrk[2]
Peoplechkmrk[2]chkmrk[2]People Web Servicechkmrk[2]chkmrk[2]
Permissionschkmrk[2]chkmrk[2]Permissions Web Servicechkmrk[2]chkmrk[2]
SiteDatachkmrk[2]chkmrk[2]SiteData Web Servicechkmrk[2]chkmrk[2]
Siteschkmrk[2]chkmrk[2]Sites Web Service 20072010chkmrk[2]chkmrk[2]
Users and Groupschkmrk[2]chkmrk[2]Users and Groups Web Servicechkmrk[2]chkmrk[2]
Versionschkmrk[2]chkmrk[2]Versions Web Servicechkmrk[2]chkmrk[2]
Viewschkmrk[2]chkmrk[2]Views Web Servicechkmrk[2]chkmrk[2]
WebPartPageschkmrk[2]chkmrk[2]Web Part Pages Web Servicechkmrk[2]chkmrk[2]
Webschkmrk[2]chkmrk[2]Webs Web Servicechkmrk[2]chkmrk[2]
PublishedLinksService chkmrk[2]PublishedLinksService Web Service chkmrk[2]
Search chkmrk[2]Search Web Service chkmrk[2]
SpellCheckerchkmrk[2]SpellChecker Web Servicechkmrk[2]
UserProfileService chkmrk[2]User Profile Web Service chkmrk[2]
Workflow chkmrk[2]Workflow Web Service chkmrk[2]
Diagnostics  Diagnostics Web Servicechkmrk[2]chkmrk[2]
SocialDataService  SocialDataService Web Service chkmrk[2]
TaxonomyClientService  TaxonomyClientService Web Service chkmrk[2]

General Syntax

$().SPServices({
	operation: "operationname",
	[webURL: "/sitepath",]
	[option1: value1,]
	[option2: value2,]
	[async: false,]
	completefunc: function (xData, Status) {
		...do stuff...
	}
});

operation
The name of the Web Service operation (see the SDK documentation links above). Because the Web Services operations are named uniquely, you only need to specify the operation.

webURL
For Web Service operations where it makes sense, you can pass in a webURL to change the context for the AJAX call. By default, the current site (as determined by $().SPServices.SPGetCurrentSite) is used.

options
The options vary based on which Web Service and operation you are calling. In all instances, the options will take the same names as those described in the SDK.

async
By default, all of the Web Service operations are called asynchronously with AJAX. Generally, this will be the desired approach, but to force synchronicity, add the async: false option.

cacheXML
If set to true, the result's raw XML will be cached using jQuery promises in a similar manner to that outlined in Scot Hillier's excellent post Utilizing Promises in SharePoint 2013 Apps. See more about how this works on theCaching page.

completefunc
A function to call on completion of the AJAX call to the Web Service:

completefunc: function(xData, Status) {
  ...do something...
},

Example

Example call for GetListItems. This example is taken directly from SPCascadeDropdowns:

$().SPServices({
	operation: "GetListItems",
	// Force sync so that we have the right values for the child column onchange trigger
	async: false,
	webURL: opt.relationshipWebURL,
	listName: opt.relationshipList,
	// Filter based on the currently selected parent column's value
	CAMLQuery: camlQuery,
	// Only get the parent and child columns
	CAMLViewFields: "<ViewFields><FieldRef Name='"+ opt.relationshipListParentColumn + "' /><FieldRef Name='"+ opt.relationshipListChildColumn + "' /></ViewFields>",
	// Override the default view rowlimit and get all appropriate rows
	CAMLRowLimit: 0,
	completefunc: function(xData, Status) {
		...
	}

Example call for GetUserInfo:

waitMessage = "<table width='100%' align='center'><tr><td align='center'><img src='/_layouts/images/gears_an.gif'/></td></tr></table>";

$("#WSOutput").html(waitMessage).SPServices({
	operation: "GetUserInfo",
	userLoginName: "SHARE1\\demouser",
	completefunc: function (xData, Status) {
		$("#WSOutput").html("").append("<b>This is the output from the GetUserInfo operation:</b>");
		$(xData.responseXML).find("User").each(function() {
			$("#WSOutput").append("<li>ID: "+ $(this).attr("ID") + "</li>");
			$("#WSOutput").append("<li>Sid: "+ $(this).attr("Sid") + "</li>");
			$("#WSOutput").append("<li>Name: "+ $(this).attr("Name") + "</li>");
			$("#WSOutput").append("<li>LoginName: "+ $(this).attr("LoginName") + "</li>");
			$("#WSOutput").append("<li>Email: "+ $(this).attr("Email") + "</li>");
			$("#WSOutput").append("<li>Notes: "+ $(this).attr("Notes") + "</li>");
			$("#WSOutput").append("<li>IsSiteAdmin: "+ $(this).attr("IsSiteAdmin") + "</li>");
			$("#WSOutput").append("<li>IsDomainGroup: "+ $(this).attr("IsDomainGroup") + "</li>");
			$("#WSOutput").append("<hr/>");
		});
	}
});

Viewing all articles
Browse latest Browse all 6517

Trending Articles