Microsoft Course Microsoft Official Share Point 2013 ClientSide

  • Slides: 28
Download presentation
Microsoft Course Microsoft. Official Share. Point 2013 ® Client-Side Share. Point Development Share. Point

Microsoft Course Microsoft. Official Share. Point 2013 ® Client-Side Share. Point Development Share. Point Practice

Module Overview • Using the Client-Side Object Model for Managed Code • Using the

Module Overview • Using the Client-Side Object Model for Managed Code • Using the Client-Side Object Model for Java. Script • Using the REST API with Java. Script

Lesson 1: Using the Client-Side Object Model for Managed Code • Overview of the

Lesson 1: Using the Client-Side Object Model for Managed Code • Overview of the Managed CSOM • Using Client Context, Loading Objects, Executing Queries • Reading Share. Point Data • Changing Share. Point Data • Handling Server-Side Errors

Overview of the Managed CSOM • When to use the Managed CSOM • Components

Overview of the Managed CSOM • When to use the Managed CSOM • Components of the Managed CSOM • Using the CSOM proxy Share. Point Application Custom C# Code Managed CSOM Content DB JSON Client. svc Service Proxy XML

Using Client Context, Loading Objects, Executing Queries public string get. Site. Collection. Url ()

Using Client Context, Loading Objects, Executing Queries public string get. Site. Collection. Url () { string app. Web. Url = Page. Request["SPApp. Web. Url"]; using (Client. Context context = new Client. Context(app. Web. Url)); { Site site. Collection = context. Site; context. Load(site. Collection, s=>s. Title, s=>s. Server. Relative. Url); context. Execute. Query(); return site. Collection. Url; } }

Reading Share. Point Data • Obtain a collection of lists in a site: List.

Reading Share. Point Data • Obtain a collection of lists in a site: List. Collection all. Lists = current. Web. Lists; • Obtain a list by its title: List suggestions. List = all. Lists. Get. By. Title("Suggestions"); • Obtain items in a list by using a CAML query:

Changing Share. Point Data • Creating lists: Create a List. Creation. Information object •

Changing Share. Point Data • Creating lists: Create a List. Creation. Information object • Pass the object to Web. Lists. Add() • • Creating items: Create a List. Item. Creation. Information object • Pass the object to List. Add. Item() • • Updating items: Set fields on an item • Call Item. Update() • • Deleting items: • Call Item. Delete. Object()

Handling Server-Side Errors • Use an exception handling scope for server-side errors as in

Handling Server-Side Errors • Use an exception handling scope for server-side errors as in the Java. Script CSOM • Use using() { } code blocks to ensure correct disposal of objects • Make sure there is only one call to Execute. Query() after the exception handling scope is disposed of

Lab A: Using the Client-Side Object Model for Managed Code • Exercise 1: Create

Lab A: Using the Client-Side Object Model for Managed Code • Exercise 1: Create the Mileage Claim List • Exercise 2: Add Mileage Claim Creation Code • Exercise 3: Display Mileage Claims on the App Start Page

Lab Scenario The field sales team at Contoso regularly submits expense claims for mileage.

Lab Scenario The field sales team at Contoso regularly submits expense claims for mileage. Because of the fluctuating price of fuel, variable tax rates, and other factors, some salespeople find it difficult to calculate their expense claims accurately. To help the sales team, you will implement an app that calculates mileage expenses. To ensure that the app always uses the latest formula and to remove the processing burden from client browsers, you decide to create an autohosted app. The app will prompt users for the required information, calculate the claimable expenses, and then submit the claim on behalf of the salesperson.

Lab Review • In Exercise 2, how did you ensure that all pages in

Lab Review • In Exercise 2, how did you ensure that all pages in the remote web could locate the app web in Share. Point to read or write data?

Lesson 2: Using the Client-Side Object Model for Java. Script • Overview of the

Lesson 2: Using the Client-Side Object Model for Java. Script • Overview of the CSOM for Java. Script • Using the Client Context Object • Loading Objects and Running Queries • Demonstration: How to Use load and load. Query • Reading Share. Point Data • Changing Share. Point Data • Handling Server-Side Errors

Overview of the CSOM for Java. Script • Components of the CSOM • Linking

Overview of the CSOM for Java. Script • Components of the CSOM • Linking to script libraries • Using the CSOM proxy Share. Point App Custom Java. Script CSOM Content database JSON Client. svc Service proxy XML

Using the Client Context Object get. Site. Collection = function () { context =

Using the Client Context Object get. Site. Collection = function () { context = new SP. Client. Context. get_current(); site. Collection = context. get_site(); context. load(site. Collection); context. execute. Query. Async(on. Success, on. Failure); }, on. Success = function () { alert("URL: " + site. Collection. get_url()); }, on. Failure = function(sender, args) { alert("Could not obtain the site collection URL"); }

Loading Objects and Running Queries • Loading objects The context. load() method • The

Loading Objects and Running Queries • Loading objects The context. load() method • The context. load. Query() method • • Executing operations Asynchronous • Synchronous •

Demonstration: How to Use load and load. Query In this demonstration, you will see

Demonstration: How to Use load and load. Query In this demonstration, you will see how to: • Use the load method from the Java. Script CSOM to load items • Loop through results by using an enumerator • Use the load. Query method from the Java. Script CSOM to load items • Loop through results by using the for. Each method

Reading Share. Point Data • Reading all the lists in a site • Getting

Reading Share. Point Data • Reading all the lists in a site • Getting a list by title • Getting items in a list by using a CAML query • Getting an item by ID

Changing Share. Point Data • Creating a new list in a site • Creating

Changing Share. Point Data • Creating a new list in a site • Creating a new item in a list • Using SP. List. Item. Creation. Information • Updating an existing item in a list • Deleting an item from a list

Handling Server-Side Errors • By default, a server-side error causes the whole batch of

Handling Server-Side Errors • By default, a server-side error causes the whole batch of operations to fail. • To avoid this, you can use an exception handling scope to define server-side try/catch/finally blocks var e = new SP. Exception. Handling. Scope(context); var s = e. start. Scope(); var t = e. start. Try(); // This is the try block. t. dispose(); var c = e. start. Catch(); // This is the catch block. c. dispose();

Lesson 3: Using the REST API with Java. Script • Overview of the REST

Lesson 3: Using the REST API with Java. Script • Overview of the REST API • Share. Point REST API URLs • Reading Data • Creating and Updating Data

Overview of the REST API RESTful services: • Use logical URLs to specify objects

Overview of the REST API RESTful services: • Use logical URLs to specify objects • Use HTTP verbs to specify operations • Use OData to exchange data The Share. Point Client. svc service is a REST API $. get. JSON( "http: //intranet. contoso. com/_api/web", function (data) { alert('The Share. Point site is called: ' + data. d. Title); } )

Share. Point REST API URLs • Address of the REST API • URLs for

Share. Point REST API URLs • Address of the REST API • URLs for common Share. Point objects • Using OData operators http: //intranet. contoso. com /_api/web/lists/getbytitle("My. List")/items ? $select=ID, Title &$order=Title &$filter=startswith(Title, ”A”)

Reading Data • Using the _sp. Page. Context. Info. web. Server. Relative. Url property

Reading Data • Using the _sp. Page. Context. Info. web. Server. Relative. Url property • The j. Query get. JSON() function • The j. Query ajax() function

Creating and Updating Data • Creating new items Formulate a URL to the parent

Creating and Updating Data • Creating new items Formulate a URL to the parent list in the REST API • Use the POST verb • • Updating existing items Formulate a URL to the item itself • Use the PATCH, MERGE, or PUT verbs • • Deleting items Formulate a URL to the item itself • Use the DELETE verb • • Always pass a form digest

Lab B: Using the REST API with Java. Script • Exercise 1: Creating List

Lab B: Using the REST API with Java. Script • Exercise 1: Creating List Relationships • Exercise 2: Add Vote Recording • Exercise 3: Display Votes for Each Suggestion

Lab Scenario The management team at Contoso has asked that you extend the Site

Lab Scenario The management team at Contoso has asked that you extend the Site Suggestions app to include more sophisticated functionality. In particular, they want users to be able to vote on suggestions made by others. Votes can be positive or negative, and the net votes should be displayed with each item.

Lab Review • In the code that retrieves and displays votes, how did you

Lab Review • In the code that retrieves and displays votes, how did you ensure only votes for the current suggestion are retrieved from Share. Point? • In Exercise 2, you passed a form digest with REST request. Why was this form digest unnecessary in the REST request you formulated in Exercise 3?

Module Review and Takeaways • Review Question(s) • Common Issues and Troubleshooting Tips

Module Review and Takeaways • Review Question(s) • Common Issues and Troubleshooting Tips