Professional Documents
Culture Documents
Module 3 - Client Side Object Model
Module 3 - Client Side Object Model
Module 3 - Client Side Object Model
subtitle style
Custom JavaScript
Content DB
Client.svc
Service Proxy
XML
Using the Client Context Object
getSiteCollection = function () {
context = new SP.ClientContext.get_current();
siteCollection = context.get_site();
context.load(siteCollection);
context.executeQueryAsync(onSuccess, onFailure);
},
onSuccess = function () {
alert("URL: " + siteCollection.get_url());
},
onFailure = function(sender, args) {
alert("Could not obtain the site collection URL");
}
Loading Objects and Running Queries
• Loading Objects
– Context.Load()
– Context.LoadQuery()
• Execution
– ExecuteQueryAsync()
• Success
• Failure
Changing SharePoint Data
• RESTful Services:
– Use Logical URLs to specify objects
– Use HTTP verbs to specify operations
– Use OData to exchange data
http://intranet.contoso.com
/_api/web/lists/getbytitle("MyList")/items
?$select=ID,Title
&$order=Title
&$filter=startswith(Title,”A”)
Reading Data
• Deleting Items
– Formulate a URL to the item itself
– Use the DELETE verb
DEMO
REST API and JavaScript
©2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics and other product names are or may be registered trademarks and/or trademarks in the
U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft
must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after
the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.