+ All Categories
Home > Internet > Wonderful csom sps barcelona

Wonderful csom sps barcelona

Date post: 16-Apr-2017
Category:
Upload: sonja-madsen
View: 499 times
Download: 0 times
Share this document with a friend
30
Wonderful CSOM Sonja Madsen September 26 th , 2015 Barcel ona
Transcript
Page 1: Wonderful csom sps barcelona

Wonderful CSOMSonja MadsenSeptember 26th, 2015

Barcelona

Page 2: Wonderful csom sps barcelona

@sonjamadsen sp2013.blogspot.com [email protected] www.sonjasapps.com

Sonja Madsen

Best International Developer

Page 3: Wonderful csom sps barcelona

CSOM2007

SSOM

2010 2013

CSOMSharePoint

Foundation

2016 -

Page 4: Wonderful csom sps barcelona

Client-Side Object Model

Lists and Libraries

ManagedMetadata

User Profiles

Workflows

Search

Site

Publishing

Analytics

BISocial

Add-ins, apps, farm solutions

_API

CSOM in SharePoint 2013

Page 5: Wonderful csom sps barcelona

CSOM advantages over RESTSSOM, JSOM, CSOM with PowerShellWhat’s new

CSOM

Page 6: Wonderful csom sps barcelona

DEMO, MVC, the app

Page 7: Wonderful csom sps barcelona

JavaScript Silverlight .NETOData

and REST

Lists and Libraries

ManagedMetadata

User Profiles

Workflows

Search

Site

Publishing

Analytics

BI

CSOM

Social

_API

Page 8: Wonderful csom sps barcelona

CSOM & REST

Page 9: Wonderful csom sps barcelona

Resembles SharePoint Server API, SSOMStrongly typedBatch requestsConnection authentication to the serverRemote error handlingLambda expressionsObject BrowserCovers more SharePoint API than REST

CSOM Advantages

Page 10: Wonderful csom sps barcelona

using (var clientContext = spContext.CreateUserClientContextForSPHost())

{

if (clientContext != null)

{

WebCreationInformation creation = new WebCreationInformation();

creation.Url = webTitle;

creation.Title = webTitle;

Web newWeb = clientContext.Web.Webs.Add(creation);

clientContext.Load(newWeb);

clientContext.ExecuteQuery();

}

}

Strongly Typed CSOM

Page 11: Wonderful csom sps barcelona

Query.ajax({ url: "http://<site url>/_api/web/webinfos/add", type: "POST", data: JSON.stringify( {'parameters': { '__metadata': { 'type': 'SP.WebInfoCreationInformation' }, 'Url': 'RestSubWeb', 'Title': 'RestSubWeb', 'Description': 'REST created web', 'Language':1033, 'WebTemplate':'sts', 'UseUniquePermissions':false} } ), headers: { "accept": "application/json; odata=verbose", "content-type":"application/json;odata=verbose", "content-length": <length of post body>, "X-RequestDigest": $("#__REQUESTDIGEST").val() }, success: doSuccess, error: doError });

Create site with REST

Page 12: Wonderful csom sps barcelona

Batch Requests

Context, Web

Add a List

Add a Column

context.Load(…context.ExecuteQuery();

Add anotherColumn

CSOM

REST

_API

Page 13: Wonderful csom sps barcelona

REST call form digest value expires after 30 min.

Connection Authentication to the server

Page 14: Wonderful csom sps barcelona

Connection Authentication to the server$.ajax({ url: _spPageContextInfo.siteAbsoluteUrl + "/_api/web/,,,", method: "POST", headers: { "Accept": "application/json; odata=verbose", "X-RequestDigest": $('#__REQUESTDIGEST').val() }, success: function (data) {}, error: function (data, errorCode, errorMessage) {}});

Page 15: Wonderful csom sps barcelona

Structured Remote Exception Handling

Context, Web

Add a List

_api

Add a Column

If the List exists

Add anotherColumn

TRY CATCH

Context, Web

Add a List

Add a Column

Add anotherColumn

FINALLY

Page 16: Wonderful csom sps barcelona

DEMO

Page 17: Wonderful csom sps barcelona

context.Load(web);

.Where()

.Include()

.OrderBy()

Lambda Expressions

Page 18: Wonderful csom sps barcelona

Object Browser

Page 19: Wonderful csom sps barcelona

DEMO

Page 20: Wonderful csom sps barcelona

Server Side SSOM CSOMusing (SPSite site = new SPSite(projectweburl)) { using (SPWeb web = site.RootWeb) { web.AllowUnsafeUpdates = true; … SPWebTemplate webTemplate = webTemplates[TemplateI]; … //create project site web.Webs.Add(webUrl, webTitle, "", uint.Parse(lcid), webTemplate, false, false); web.Update();

}}

using (var clientContext = spContext.CreateUserClientContextForSPHost()) { if (clientContext != null) { WebCreationInformation creation = new WebCreationInformation(); creation.Url = webTitle; creation.Title = webTitle; Web newWeb = clientContext.Web.Webs.Add(creation);

clientContext.Load(newWeb); clientContext.ExecuteQuery();}}

Page 21: Wonderful csom sps barcelona

SSOM CSOMThmxTheme.SetThemeUrlForWeb(siteWeb, currentweb.ServerRelativeUrl + "/_catalogs/theme/SK.thmx"); siteWeb.Update();

siteWeb.ApplyTheme(colorPaletteFile.ServerRelativeUrl, fontSchemeFile.ServerRelativeUrl,null, true); siteWeb.Update(); clientContext.ExecuteQuery();

Page 22: Wonderful csom sps barcelona

CSOM with JavaScript = JSOM

using (var context = spContext.CreateUserClientContextForSPHost()) { if (clientContext != null) {WebCreationInformation creation = new WebCreationInformation();creation.Url = webTitle;creation.Title = webTitle; Web newWeb = clientContext.Web.Webs.Add(creation);

context.Load(newWeb);context.ExecuteQuery();}}

var context = new SP.ClientContext();

var creation = new SP.WebCreationInformation();

creation.set_title(webTitle);

creation.set_url(webTitle);

creation.set_webTemplate('STS#0');

var newWeb = context.get_web().add(creation);

context.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

}

C#JavaScript

Page 23: Wonderful csom sps barcelona

ClientContext context = new ClientContext("http://SiteUrl");

WebCreationInformation creation = new WebCreationInformation();

creation.Url = "webTitle";

creation.Title = "webTitle";

Web newWeb = context.Web.Webs.Add(creation);

context.Load(newWeb);

context.ExecuteQuery();

CSOM with PowerShell

using (var context = spContext.CreateUserClientContextForSPHost()) { if (clientContext != null) {WebCreationInformation creation = new WebCreationInformation();creation.Url = webTitle;creation.Title = webTitle; Web newWeb = clientContext.Web.Webs.Add(creation);

context.Load(newWeb);context.ExecuteQuery();}}

C#PowerShell

Page 24: Wonderful csom sps barcelona

CSOM Online

What’s New

Microsoft.SharePointOnline.CSOMManage regional settings of a siteManage language settings of a siteManage auditing settings of a siteControl advanced settings for document setsSupport for upcoming enhanced migration APIsControl sandbox solution settings in site collection levelSecondary contact in site collection levelSharing settings

Page 25: Wonderful csom sps barcelona

Visual Studio 2015

Page 26: Wonderful csom sps barcelona

Summary

JavaScript Silverlight .NETOData

and REST

CSOM

_API

Page 27: Wonderful csom sps barcelona

Get stamps from all the sponsorsDeposit the passport to enter the prize raffle

Good luck!

The SPSBCN Passport

Page 28: Wonderful csom sps barcelona

FREE BEER!Get your ticket at the registration desk

Network and have fun with your colleagues!

SharePint sponsored by

Michael Collins Pub

Plaça de Sagrada Família

Starts at 19:30h

Page 29: Wonderful csom sps barcelona

They help us improve for SharePoint Saturday 2016!

Remember to fill your evaluation forms

Page 30: Wonderful csom sps barcelona

Thanks to our Sponsors


Recommended