Shar
ePoi
nt 2
013
Serv
er O
bjec
t Mod
el
+91 – 90305 18717 http://staygreenacademy.com/
SharePoint 2013 Server Object Modelby
SharePoint 2013 Server Object Model
Shar
ePoi
nt 2
013
Serv
er O
bjec
t Mod
el
+91 – 90305 18717 http://staygreenacademy.com/
What is Server Object Model ?Set of classes and namespaces separated into .Net Libraries.
What is the use of these classes?Allows to develop server-side programs interacting with the SharePoint engine
What is server-side programs/solutions?Set of instruction running on Server
How to use Server Object ModelAdd the library/assembly as a reference in your Visual Studio project.
When is it best to use Server Object Model?Only when a solution requires to talk with SharePoint farm/engine. This solution is called Farm or
Sandboxed solution based on how it is deployed.
Introduction
Shar
ePoi
nt 2
013
Serv
er O
bjec
t Mod
el
+91 – 90305 18717 http://staygreenacademy.com/
Introduction
What is the initial best development approach?Develop solution using Console application in initial stage.
Why ?Its speeds up the development processIt does not require deployment for testing
Any cautions ?Make sure project is targeted to 4.5 Framework, and 64x Platform
Which is the main library need to reference?Microsoft.SharePoint.dll
Where Microsoft.SharePoint.dll and other assemblies are located?Under 15Hive\ISAPI (15Hive = C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\)
Shar
ePoi
nt 2
013
Serv
er O
bjec
t Mod
el
+91 – 90305 18717 http://staygreenacademy.com/
Practical
Objects Types
Located or defined in the namespace starts with
Microsoft.SharePoint.*
Microsoft.Office.*
Type or Class names starts with SP
Examples : SPFarm, SPWebApplication, SPSite, SPWeb etc…
Shar
ePoi
nt 2
013
Serv
er O
bjec
t Mod
el
+91 – 90305 18717 http://staygreenacademy.com/
Object Hierarchy
SPFarm
SPService
SPWebApplication
SPSite
SPWeb
SPList
SPWeb
SPList SPList
SPListItem
Shar
ePoi
nt 2
013
Serv
er O
bjec
t Mod
el
+91 – 90305 18717 http://staygreenacademy.com/
PracticalCreating first LIST
Programmatically.
Shar
ePoi
nt 2
013
Serv
er O
bjec
t Mod
el
+91 – 90305 18717 http://staygreenacademy.com/
Using
SPSite
SPWeb
Site.AllWebs
Web.Title
Web.Dispose()
Display All sub sites under a site collections
Practical
Shar
ePoi
nt 2
013
Serv
er O
bjec
t Mod
el
+91 – 90305 18717 http://staygreenacademy.com/
Using
SPSite
SPWeb
Site.AllWebs
Web.Title
Web.Dispose()
Display All Sites
Practical
Shar
ePoi
nt 2
013
Serv
er O
bjec
t Mod
el
+91 – 90305 18717 http://staygreenacademy.com/
siteCollection.RootWeb
SPList
site.Lists.TryGetList(“”)
list.Delete
site.Lists.Add(…)
list.Fields.Add(…)
SPFieldType
SPView
list.DefaultView
defaultView.ViewFields.Add(…)
SPListItem
list.Items.Add()
Practical
Shar
ePoi
nt 2
013
Serv
er O
bjec
t Mod
el
+91 – 90305 18717 http://staygreenacademy.com/
Console ApplicationPractice 1 : How to display name of Lists available in a site ?
Practice 2 : How to display List of sites under a site collection ?
Practice 3 : How to display List Items of a List ?
Practice 3 : How to create List ?
Practice 4 : How to create List Item ?
Practice 5 : How to create a Site ?
Practice 6 : How to Add a Field in a List?
Practice 7 : How to include Field in a Default View
Practical
Shar
ePoi
nt 2
013
Serv
er O
bjec
t Mod
el
+91 – 90305 18717 http://staygreenacademy.com/
Thank You for Watching
SharePoint 2013 Server Object Model
by