KEMBAR78
Share point development 101 | PPTX
SharePoint
Development 101
St. Louis Metro East .NET User Group
June 17, 2014
Becky Bertram
Owner, Savvy Technical Solutions
www.savvytechnicalsolutions.com
@beckybertram
About Me
• Owner of Savvy Technical Solutions
in O’Fallon, IL
• 5 time SharePoint MVP
• Co-author of Wrox SharePoint Six-in-One
• Co-author of several Microsoft exams
• Instructor at CAIT @ Wash U
• Started working with MS CMS in 2001,
SharePoint in 2006
• Wife of Ryan, mother of Lilly and Abby (3 and 1 years)
• Hobbies: sleeping and showering
Flavors of SharePoint
• SharePoint Team Services (STS) and SharePoint
Portal Server (SPS)
• Windows SharePoint Services (2.0 and 3.0) and
Microsoft Office SharePoint Server 2007 (MOSS)
• SharePoint Foundation 2010 and SharePoint
Server 2010
• SharePoint Foundation 2013 and SharePoint
Server 2013
-----------------
• BPOS
• SharePoint Online (part of Office 365)
What is SharePoint?
• Web-based too for building intranet, extranet, or internet applications
• Allows users to quickly spin up sites, manage documents, search for content
• Enterprise tools for managing external content, business processes, external
data, etc.
• Social and collaborative tool to encourage teams to work together toward
common goals
• Enterprise search engine, document preview, etc.
• Front-end for other MS products, such as SSRS, Project, etc.
• Bottom line: platform more than a product,
a tool belt full of tools you get to choose
from to build your application
Making Changes to
SharePoint
• Configuration
• Customization
• Development
Configuration
• Configuring application features:
• Setting up Service Applications such as
Search, BCS, Managed Metadata, etc.
• Done with Central Admin or PowerShell
• Configuring Web Parts:
• Setting web part properties so they
demonstrate the proper behavior
• Done with SharePoint Designer (SPD) or
through the browser
Customization
• Content stored in the content DB
• Application files on WFE servers
• SP uses app files on server to serve as
templates
• Customization is when you deviate from
the template and SP stores the changed
version in the content DB
• Customization usually done in SPD
Development
• Implies the use of development tools
such as Visual Studio
• Code-based applications that are file-
based and can be checked into source
control
• Changes can be deployed via solution
packages or as SharePoint apps to
multiple environments
Visual Studio SharePoint
Templates
SharePoint App Template
Where’s Workflow?
• Workflow no longer part of available VS
templates
• WF now declarative in SP. Custom workflows
run in WM.
• If you need to access custom workflow logic,
you can even write a web service to call out
to.
• Since WF is now just an XML node, can be
added as an item to a “regular” SP project.
Remote Event Receiver
• An event receiver is code that fires when
an activity happens such as a web site is
created or deleted, an item is added or
deleted from a list or library, etc.
• Legacy event handlers deployed within
assemblies in farm solutions
• Remote event receivers are exposed web
services that SharePoint calls when the
event happens. Your custom code can
then use CSOM if it needs to access SP
data, or it can act on external LOB data.
VS Project Items
Solution Packages
• A CAB file with a WSP extension
• Solution Manifest is an XML file that gives
SP instructions about what to do with files in
the package
• Packages typically contain:
• Flat files to be installed in the SharePoint
installation directory on the WFE
• Assemblies to be put in the GAC
• Instructions about content to be added to a
content DB
• Controls to be marked as “safe” in the web.config
Feature
• A unit a functionality than can be
implemented at the farm, web
application, site collection, or site level
• Can execute code and/or add something
to the content databases.
• Examples: add a master page and CSS
to the top level site, add a content type
or site column to the site collection, add
a list definition or list instance to your
site; kick off a timer job; add a link to
the ribbon or the site settings page.
Farm Solution
• Solution package deployed within a SP farm.
Can be deployed to a particular web
application within SP. (Web app typically
connected w/ one or more IIS web sites.)
• Gracefully handles added servers to the
farm
• Files deployed to file system; assemblies
(typically) deployed in GAC; code executes
in web server process (W3WP.exe)
• Deprecated
Sandboxed Solutions
• Code executes in a separate (sandboxed) worker process
• If too many resources used, can be shut down. Prevents
unintended consequences in multi-tenant environment.
• Solutions uploaded by site collection admins
• Server resource throttling handled by farm admins
• (Mostly) deprecated
• Uses SSOM with restrictions (can’t access objects above
site collection level, can’t elevate permissions)
Server-Side Object Model
• SharePoint managed (i.e. .NET)
assemblies contain SharePoint API
• Assemblies installed on the SharePoint
WFE, ergo development must take place
on a SharePoint server (usually VM)
• This approach is deprecated, but none of
the APIs themselves have been
deprecated.
SSOM code example
using Microsoft.SharePoint;
using(SPSite site = new SPSite("http://intranet"))
{
using(SPWeb web = site.OpenWeb(“deprtments/hr"))
{
using(SPWeb root = site) { ... }
}
}
Client-side Object Model
• Microsoft-sanctioned way of accessing data and
functionality inside SharePoint server from
outside SharePoint (i.e. on a “client”).
• Means no custom code running on SharePoint
server except what has been sanctioned by MS
to work via their object model
• The future
• OM augmented all the time to get parity with
older SSOM
Managed Code CSOM
• .NET assemblies that can run on a non-
SharePoint server to access data inside
SharePoint
• Windows app
• Test jigs
• Data import
• Exposed web services
• Etc
• SharePoint apps
• Externally hosted web sites
ECMA Script CSOM
• (Pretty much JavaScript) way of
accessing data inside SharePoint from a
web page
• Web page can be hosted in SharePoint,
or hosted outside SharePoint (perhaps on
a SharePoint App page)
• Reference JS library such as sp.core.js
and sp.core.debug.js)
• Can be used with Jquery or AJAX libraries
CSOM Example
function retrieveWebSiteProperties(siteUrl) {
var clientContext = new SP.ClientContext(siteUrl);
this.oWebsite = clientContext.get_web();
clientContext.load(this.oWebsite, 'Title', 'Created');
clientContext.executeQueryAsync(
Function.createDelegate(this, this.onQuerySucceeded),
Function.createDelegate(this, this.onQueryFailed) );
}
function onQuerySucceeded(sender, args) {
alert('Title: ' + this.oWebsite.get_title() + '
Created: ' + this.oWebsite.get_created());
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + 'n' +
args.get_stackTrace());
}
ODATA and REST
• Way of accessing data within SharePoint
using a URL, and HTTP Request and
Response objects
• Handled by client.svc web service in SP,
aliased with _api.
• To access site data, use the site URL
followed by _api, such as
http://intranet/hr/_api
• Append which object you want to work with
after the _api, such as /site, /web, or /lists,
such as:
http://intranet/hr/_api/lists/getbytitle(‘employees')
ODATA and REST Cont’d
• Use HTTP commands to carry out CRUD
operations:
• POST (Create)
• GET (Read)
• MERGE or PUT (Update)
• DELETE
• Results returned using JSON or ATOM
• Very fast response. Useful for
autocomplete, etc.
Using ODATA with JS
function getListItem(url, listname, id, complete,
failure) {
$.ajax({
url: url + "/_api/lists/getbytitle('" + listname +
"')/items(" + id + ")",
method: "GET",
headers: { "Accept": "application/json;
odata=verbose" },
success: function (data) {
complete(data);
},
error: function (data) {
failure(data);
}
});
}
}
SharePoint Web Services API
• Deprecated way of accessing SharePoint
• Stored in _vti_bin:
http://Site/_vti_bin/Lists.asmx
• However, fairly robust. Using SPServices,
can use SP Web Services API as JQuery
on the client (SPServices.codeplex.com)
SPServices Example
<script type="text/javascript" src="filelink/jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="filelink/jquery.SPServices-
0.6.2.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$().SPServices({
operation: "GetListItems",
async: false,
listName: "Announcements",
CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row")
.each(function() {
var liHtml = "<li>" + $(this).attr("ows_Title") + "</li>";
$("#tasksUL").append(liHtml);
});
}
});
});
</script>
<ul id="tasksUL"/>
SharePoint App Model
• Much like the concept of an “app store”
for your phone or tablet
• Office Store is for publicly sold apps
• Corporate Catalog is for apps you create
and load just in your farm
• Goal is for ZERO custom code to run
inside the SP environment
App Locations
• Host Web:
• Location where app is installed. Web from
which a user navigates to app
• Can contain an App Part, which to user feels
like a web part, but is actually an IFrame to
a page in your app.
• App web:
• Location of your actual app.
• Provider-hosted: located OUTSIDE of SP
• SharePoint-hosted: located in a subsite (with
a different URL). Still no server-side code
• Can be the same or unique
Napa
Napa app is a web-based tool for
generating apps on the fly in your Office
365 developer site
Questions?

Share point development 101

  • 1.
    SharePoint Development 101 St. LouisMetro East .NET User Group June 17, 2014 Becky Bertram Owner, Savvy Technical Solutions www.savvytechnicalsolutions.com @beckybertram
  • 2.
    About Me • Ownerof Savvy Technical Solutions in O’Fallon, IL • 5 time SharePoint MVP • Co-author of Wrox SharePoint Six-in-One • Co-author of several Microsoft exams • Instructor at CAIT @ Wash U • Started working with MS CMS in 2001, SharePoint in 2006 • Wife of Ryan, mother of Lilly and Abby (3 and 1 years) • Hobbies: sleeping and showering
  • 3.
    Flavors of SharePoint •SharePoint Team Services (STS) and SharePoint Portal Server (SPS) • Windows SharePoint Services (2.0 and 3.0) and Microsoft Office SharePoint Server 2007 (MOSS) • SharePoint Foundation 2010 and SharePoint Server 2010 • SharePoint Foundation 2013 and SharePoint Server 2013 ----------------- • BPOS • SharePoint Online (part of Office 365)
  • 4.
    What is SharePoint? •Web-based too for building intranet, extranet, or internet applications • Allows users to quickly spin up sites, manage documents, search for content • Enterprise tools for managing external content, business processes, external data, etc. • Social and collaborative tool to encourage teams to work together toward common goals • Enterprise search engine, document preview, etc. • Front-end for other MS products, such as SSRS, Project, etc. • Bottom line: platform more than a product, a tool belt full of tools you get to choose from to build your application
  • 5.
    Making Changes to SharePoint •Configuration • Customization • Development
  • 6.
    Configuration • Configuring applicationfeatures: • Setting up Service Applications such as Search, BCS, Managed Metadata, etc. • Done with Central Admin or PowerShell • Configuring Web Parts: • Setting web part properties so they demonstrate the proper behavior • Done with SharePoint Designer (SPD) or through the browser
  • 7.
    Customization • Content storedin the content DB • Application files on WFE servers • SP uses app files on server to serve as templates • Customization is when you deviate from the template and SP stores the changed version in the content DB • Customization usually done in SPD
  • 8.
    Development • Implies theuse of development tools such as Visual Studio • Code-based applications that are file- based and can be checked into source control • Changes can be deployed via solution packages or as SharePoint apps to multiple environments
  • 9.
  • 10.
  • 11.
    Where’s Workflow? • Workflowno longer part of available VS templates • WF now declarative in SP. Custom workflows run in WM. • If you need to access custom workflow logic, you can even write a web service to call out to. • Since WF is now just an XML node, can be added as an item to a “regular” SP project.
  • 12.
    Remote Event Receiver •An event receiver is code that fires when an activity happens such as a web site is created or deleted, an item is added or deleted from a list or library, etc. • Legacy event handlers deployed within assemblies in farm solutions • Remote event receivers are exposed web services that SharePoint calls when the event happens. Your custom code can then use CSOM if it needs to access SP data, or it can act on external LOB data.
  • 13.
  • 14.
    Solution Packages • ACAB file with a WSP extension • Solution Manifest is an XML file that gives SP instructions about what to do with files in the package • Packages typically contain: • Flat files to be installed in the SharePoint installation directory on the WFE • Assemblies to be put in the GAC • Instructions about content to be added to a content DB • Controls to be marked as “safe” in the web.config
  • 15.
    Feature • A unita functionality than can be implemented at the farm, web application, site collection, or site level • Can execute code and/or add something to the content databases. • Examples: add a master page and CSS to the top level site, add a content type or site column to the site collection, add a list definition or list instance to your site; kick off a timer job; add a link to the ribbon or the site settings page.
  • 16.
    Farm Solution • Solutionpackage deployed within a SP farm. Can be deployed to a particular web application within SP. (Web app typically connected w/ one or more IIS web sites.) • Gracefully handles added servers to the farm • Files deployed to file system; assemblies (typically) deployed in GAC; code executes in web server process (W3WP.exe) • Deprecated
  • 17.
    Sandboxed Solutions • Codeexecutes in a separate (sandboxed) worker process • If too many resources used, can be shut down. Prevents unintended consequences in multi-tenant environment. • Solutions uploaded by site collection admins • Server resource throttling handled by farm admins • (Mostly) deprecated • Uses SSOM with restrictions (can’t access objects above site collection level, can’t elevate permissions)
  • 18.
    Server-Side Object Model •SharePoint managed (i.e. .NET) assemblies contain SharePoint API • Assemblies installed on the SharePoint WFE, ergo development must take place on a SharePoint server (usually VM) • This approach is deprecated, but none of the APIs themselves have been deprecated.
  • 19.
    SSOM code example usingMicrosoft.SharePoint; using(SPSite site = new SPSite("http://intranet")) { using(SPWeb web = site.OpenWeb(“deprtments/hr")) { using(SPWeb root = site) { ... } } }
  • 20.
    Client-side Object Model •Microsoft-sanctioned way of accessing data and functionality inside SharePoint server from outside SharePoint (i.e. on a “client”). • Means no custom code running on SharePoint server except what has been sanctioned by MS to work via their object model • The future • OM augmented all the time to get parity with older SSOM
  • 21.
    Managed Code CSOM •.NET assemblies that can run on a non- SharePoint server to access data inside SharePoint • Windows app • Test jigs • Data import • Exposed web services • Etc • SharePoint apps • Externally hosted web sites
  • 22.
    ECMA Script CSOM •(Pretty much JavaScript) way of accessing data inside SharePoint from a web page • Web page can be hosted in SharePoint, or hosted outside SharePoint (perhaps on a SharePoint App page) • Reference JS library such as sp.core.js and sp.core.debug.js) • Can be used with Jquery or AJAX libraries
  • 23.
    CSOM Example function retrieveWebSiteProperties(siteUrl){ var clientContext = new SP.ClientContext(siteUrl); this.oWebsite = clientContext.get_web(); clientContext.load(this.oWebsite, 'Title', 'Created'); clientContext.executeQueryAsync( Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed) ); } function onQuerySucceeded(sender, args) { alert('Title: ' + this.oWebsite.get_title() + ' Created: ' + this.oWebsite.get_created()); } function onQueryFailed(sender, args) { alert('Request failed. ' + args.get_message() + 'n' + args.get_stackTrace()); }
  • 24.
    ODATA and REST •Way of accessing data within SharePoint using a URL, and HTTP Request and Response objects • Handled by client.svc web service in SP, aliased with _api. • To access site data, use the site URL followed by _api, such as http://intranet/hr/_api • Append which object you want to work with after the _api, such as /site, /web, or /lists, such as: http://intranet/hr/_api/lists/getbytitle(‘employees')
  • 25.
    ODATA and RESTCont’d • Use HTTP commands to carry out CRUD operations: • POST (Create) • GET (Read) • MERGE or PUT (Update) • DELETE • Results returned using JSON or ATOM • Very fast response. Useful for autocomplete, etc.
  • 26.
    Using ODATA withJS function getListItem(url, listname, id, complete, failure) { $.ajax({ url: url + "/_api/lists/getbytitle('" + listname + "')/items(" + id + ")", method: "GET", headers: { "Accept": "application/json; odata=verbose" }, success: function (data) { complete(data); }, error: function (data) { failure(data); } }); } }
  • 27.
    SharePoint Web ServicesAPI • Deprecated way of accessing SharePoint • Stored in _vti_bin: http://Site/_vti_bin/Lists.asmx • However, fairly robust. Using SPServices, can use SP Web Services API as JQuery on the client (SPServices.codeplex.com)
  • 28.
    SPServices Example <script type="text/javascript"src="filelink/jquery-1.6.1.min.js"></script> <script type="text/javascript" src="filelink/jquery.SPServices- 0.6.2.min.js"></script> <script language="javascript" type="text/javascript"> $(document).ready(function() { $().SPServices({ operation: "GetListItems", async: false, listName: "Announcements", CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>", completefunc: function (xData, Status) { $(xData.responseXML).SPFilterNode("z:row") .each(function() { var liHtml = "<li>" + $(this).attr("ows_Title") + "</li>"; $("#tasksUL").append(liHtml); }); } }); }); </script> <ul id="tasksUL"/>
  • 29.
    SharePoint App Model •Much like the concept of an “app store” for your phone or tablet • Office Store is for publicly sold apps • Corporate Catalog is for apps you create and load just in your farm • Goal is for ZERO custom code to run inside the SP environment
  • 30.
    App Locations • HostWeb: • Location where app is installed. Web from which a user navigates to app • Can contain an App Part, which to user feels like a web part, but is actually an IFrame to a page in your app. • App web: • Location of your actual app. • Provider-hosted: located OUTSIDE of SP • SharePoint-hosted: located in a subsite (with a different URL). Still no server-side code • Can be the same or unique
  • 31.
    Napa Napa app isa web-based tool for generating apps on the fly in your Office 365 developer site
  • 32.