29
SharePoint 2010 Client Side Object Model

SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

Embed Size (px)

Citation preview

Page 1: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

SharePoint 2010 Client Side Object Model

Page 2: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

Agenda• Introduction

• The Problem

• Client side vs Server Side

• Client Side Object Model– How it works– What can it do?– Limitations– Possibilities

• REST Interface

• Demonstration – REST + CSOM

• Questions

Page 3: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

Introductions

• Who am I?

• Who are you?

• “Customisation Possibilities”

Page 4: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

The Problem

• SharePoint does so much!

• But not exactly what I want

• I know – I’ll customise it!

Page 5: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

The Problem

• Custom development – Too Risky ?

• Data issues?

– Too Expensive ?• Initial development• Maintenance• Upgrade?

• More often than not, custom development requires installation of components on the Server– Promotion through environments– Time and costs associated with downtime

Page 6: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

The Problem

Customise!

Page 7: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

The Problem

$@#%$*&!

Page 8: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

The Problem

• A lot of organisations simply don't allow server side coding

• A lot of hosting situations don’t allow server side coding– BPOS / Office 360 / SharePoint Online– Web Central– Shared Tenancy / Security Issues

• Team based SharePoint development rarely performed– TFS– Proper Build Servers

Page 9: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

Client side vs Server Side

Client side

Server Side

Page 10: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

Client side vs Server SideClient Side

• Code running on client computer

• Can only interact with SharePoint via web services

• Hard to do anything of any complexity

Server Side

• Code running on server

• Can use SharePoint object model directly

• Requires installation on server

Page 11: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

Client side vs Server SideDesigner *Server Side

Web Part DevelopmentGeneric Feature DevelopmentUI Menu Feature DevelopmentSharePoint Event Handlers Custom Web ServicesCustom Field TypesCustom Page Development / Code behind Custom Windows Applications / Utilities

Custom STSADM commandsBusiness Connectivity Services (BCS)(2010)

InfoPath FormsCustom Timer JobsCustom Workflows / Custom Workflow Actions

Branding / DesignUser controlsWorkflowsAdvanced configuration…

Page 12: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

Client side vs Server Side

Client Side

?

Page 13: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

• So previously the ‘real’ client side options were:– Web Services

• Very low level• A bit complex (security)

– Scripts on page• Mainly for UI change (hiding fields, UI improvements)• “Can call web services” – yuck• VB can do some interesting things

– SharePoint designer modifications• OK – if you don’t delete everything• Customisations not as portable as would like• Know your boundaries!

Client side vs Server Side

Page 14: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

• Some client side work-arounds got quite popular:

– JPoint – series of JavaScript functionality in web parts

– HTML Calculated column –using the ‘calculated column’ to conditionally output HTML

– JavaScript web-service libraries – still yuck

Client side vs Server Side

Page 15: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

• SharePoint 2010 has two major areas of functionality in this area1. Client Side Object Model (CSOM)

2. REST Services

What’s New Already?!

Page 16: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

16

What does the client object model enable?

• Abstraction layer• Results returned as recognizable SharePoint objects

Provide powerful ways to interact with SharePoint Online data remotely without web services – providing access to objects at the site-collection level and lower within the SharePoint hierarchy.

• .NET• ECMAScript• Silverlight

Consistent developer experience across platforms

Client Side Object Model

Page 17: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

Client Side Object Model

• In a nutshell - the client side object model provides an ‘object model’ to client technologies– .Net Applications– Silverlight– JavaScript (ECMAScript)

• Each of these have a separate .dll to work with, but have very similar code

Page 18: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

Client Side Object Model

• Each of these have work with the Client web-service under the hood to provide the functionality on the server

CSOM

Page 19: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

Client Side Object Model

Page 20: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

Client Side Object Model

• Example - Delete List ( .net ):

Page 21: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

Client Side Object Model

• Example - Delete List ( JavaScript ):

Page 22: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

Client Side Object Model

Demo – CSOM

Page 23: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

Client Side Object Model

• JavaScript?– Yes – JavaScript– SharePoint 2010 Ribbon– Custom Links– Content Editor Web Parts– Added into Forms pages for lists and libraries– Scriptlets

Page 24: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

Client Side Object Model

Demo – JS

Page 25: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

Client Side Object Model

• Security– Windows Credentials by Default– Can use Forms Authentication

– Permission level setting

Page 26: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

Client Side Object ModelTips and Tricks?

– Minimise what you need to retrieve

– Know what is loaded in context and what isn’t… – Beware of IQueryable with ListItem– JavaScript only has a-sync calls…. Ouch– Use the JavaScript “Item Table”

• Holds data for the current item context

Page 27: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

Summary

• Before– Client side coding was very difficult– Either via web services or very limited in functionality

• After– Client side coding much easier– “Object Model” - like coding on the server– Similar for JavaScript, Silverlight, .Net Applications– Don’t need to develop on the server!– New Possibilities with Rest and the CSOM

Page 28: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

Reading:

Using the SharePoint Foundation 2010 Managed Client Object Modelhttp://msdn.microsoft.com/en-us/library/ee857094.aspx

Managed Client Object Modelhttp://msdn.microsoft.com/en-us/library/ee537247.aspx

Common Programming Taskshttp://msdn.microsoft.com/en-us/library/ee537013.aspx

Praveen Battulahttp://praveenbattula.blogspot.com/

Page 29: SharePoint 2010 Client Side Object Model. Agenda Introduction The Problem Client side vs Server Side Client Side Object Model – How it works – What can

Questions?