Upload
ahmed-tawfik
View
1.231
Download
7
Embed Size (px)
DESCRIPTION
sharepoint solution developer exam 70-488 notes
Citation preview
Sharepoint Development Core Solution 70-488 Skills measured
Eng.ahmed mostafa tawfikSharepoint 2013 solution developer@AMostafaTawfik
Thanks to everyone support me to finish these notes special thanks to: Eng.Mahmoud Hamed MahmoudSharePoint | Office365 Evangelist, Architect, Developer@mhamedmahmoud
This exam measures your ability to accomplish the technical tasks listed below. The percentages indicate the relative weight of each major topic area on the exam. The higher the percentage, the more questions you are likely to see on that content area on the exam.
Please note that the questions may test on, but will not be limited to, the topics described in the bulleted text.
Chapter 1 of 82
Chapter 1 Plan and design SharePoint sites (10‒15%)
Manage the site life cycle
Create a delayed site collection
// “Select template later “ Create an empty site and pick a template later time
SPSiteCollection.Add("/sites/site1", "SharePoint", null, 1033, null, "administrator", "Administrator","[email protected]")
Manage site collection disposition
1.1.1. Site Policy in SharePoint(Blog Post) Site Policies allow you to create a retention policy that can be applied to a site. Site Policy
includes the following options:1-Site Closure: The date the site is put into a "Closed" state.
denote that the site is not being actively used any longer and will be moving to the next site
lifecycle stage. Sites can be manually closed. Site owners can also manually reopen closed
sites .2-Site Deletion: The period of time following site creation or site closure that the site should
be permanently deleted. When a site is deleted all its content and sub-webs are also
deleted.3-Postponement: This option will allow a site owner to manually postpone site deletion for a
period of time determined by the Site Policy.4-E-mail Notification: Before a site is deleted, an e-mail will be sent to site owners alerting
them about the pending site deletion. Site Policy determines the period of time before
scheduled site deletion that the e-mail is sent as well as recurrence frequency and timing of
the e-mail alert.5-Read-Only Mode: This setting puts the site collection and its subwebs into a read-only
mode upon closure. Users can contact administrators to manually reopen the read-only site
collection if need.
1.1.2. ProjectPolicy.CloseProject(SPWeb web)public static void CloseProject(SPWeb web) //Closes the site. this site must have a policy applied and opened.
1.1.3. ProjectPolicy.GetCurrentlyAppliedProjectPolicyOnWeb// Returns the policy that is applied on the site , Null if there is no policy applied on the site.public static ProjectPolicy GetCurrentlyAppliedProjectPolicyOnWeb(SPWeb web)
Identify inactive site collections
1.1.4. SPSite.LastContentModifiedDatepublic DateTime LastContentModifiedDate { get; } //return System.DateTime object contain date
//Gets the date and time when the content of the site was last changed.
1.1.5. SPSite.LastSecurityModifiedDatepublic DateTime LastSecurityModifiedDate { get; } //return System.DateTime object contain date
//Gets the date and time when security on the site was last changed .
Back up and archive site collection data
Programatically : SPWebApplication myApp = SPWebApplication.Lookup(“url_of_Web_app”)
Chapter 1 of 82
SPSiteCollection mySiteCols = myApplication.Sites;// A-Backup
mySiteCols.Backup(@"full url site collection", @"\\Path+file name", override previous backup or
not);mySiteCols.Backup(@"http://Server/sites/MySiteCollection", @"\\OtherServer\WSSBackups\SiteCollections\BackupOfMySiteCollection", true);
// B- Restore
mySiteCols. Restore (@"full url site collection", @"\\Path+file name", override exist site collection
or not);mySiteCols.Restore(@"http://Server/sites/MySiteCollection", @"\\OtherServer\WSSBackups\SiteCollections\BackupOfMySiteCollection", true);
Data Protection and Recovery
Database Mirroring and Failover
Database Snapshots
SPBackupRestoreConsole Class
//Provides static methods for running and managing backup and restore operations.
Create content types
Subscribe to published content typesIntroduction to Content Types
(1) Definition: A content type is a reusable collection of metadata (columns), workflow,
behavior, and other settings for a category of items or documents in SPList or SP
Document Library manage the settings for this category in a centralized, reusable way
and can be inherited,enableing Standarize by using it in all WebSite in the SiteCollection ,
Content Types are File Format Independent could be applied to any file format
(word ,ppt,..) or without format (List Item ,Folders ,..). (2) Content Types Encapsulate Data Requirements , can include the following
information:
1. The metadata, or properties, you want to assign to this type.
2. Custom New, Edit, and Display forms to use with this content type.
3. Workflows available for items of this content type.
4. Document template For document content types
Any information necessary for custom solutions that are associated with this content
type as XML .(3) Site and List Content Types:
Site Content Type: Content Type created on siteCollection but has not yet been
added to list.
List Content Type: A Copy of the site content type and added to the list.(4) Default List Content Types:
every item has a content type assigned to it, either implicitly or explicitly ,so the list schema actually functions as the default content type of the list itself. Example Create an announcement list, and SharePoint Foundation copies the Announcement site content type locally to the list as the default list content type, create a document library and so on.
(5) Content Type Scope:
All WebSites in the SiteCollection and every SubSite .(6) Content Type IDs:
Chapter 2 of 82
Content type IDs uniquely identify the content type and are designed to be recursive.
Rules of Assignment:
The three most important built-in content types are Item, Document, and Folder. Any
content type that you assign to a document library must inherit from Document or
from a content type derived from Document. Moreover, any content type that you
assign to a list must not derive from Document. The exception to this pair of rules is
the Folder content type can exist on both lists and document libraries.(7) Content Type Groups:
The built-in content types are organized in groups such as List Content Types,
Document Content Types, Folder Content Types, and “_ Hidden”.
you can create your Group for your Content Type.
(8) Designing Content Types you should Consider:
A. Scope. Where in the site hierarchy do you want the content type to become available?B. Parent. Which existing content type you choose to derive your content type from?
Your content type will not activate correctly if the parent content type is not available in the website where your content type is created.
C. Columns. Which existing site columns are available for you to use plus Columns that are not inherited .
D. Other Resources. Will the content type require language resources? Document templates? Forms?
(9) Updating Content Types 2 Approaches:
1. Make the necessary changes to the content type // if you must make targeted,
discrete changes to a content type that is in use.
2. Create a new content type with the necessary changes, deploy it wherever the
previous content type exists, and then add the previous content type to the _Hidden
content type group. // replace a content type that is currently
in use , but still retain the current content type for items that are already assigned
that content type.
Sealed Content Types can not updated before set sealed property to false(10) Deleting Content Types :
cannot delete a site content type if it is being used as the basis for other site or list
content types, otherwords you must be sure that the GetUsages method returns an
empty listSubscribe to published content types
i) How to: Customize Content Type Syndication
(a) Ensure uniformity across lists so that they use the same content types, and therefore
the same columns.
(b) Content type can be shared within the farm or outside the farm with the managed
metadata service application.
(c) You can use the object model ContentTypePublisher class to customize content type
syndication to create a new content type, publish it, and unpublish it on the hub site.ii) ContentTypePublisher
Publishes or unpublishes a content type on the hub site.Methods: (Publish, Unpublish, IsPublished, IsContentTypeSharingEnabled )
Choose appropriate content type creation Using 3 ways:
Chapter 3 of 82
1-SharePoint Foundation user interface. //UI
2- SharePoint Foundation object model. //Code
3-Deploying a Feature that installs the content type based on an XML definition file.
//Declaretive
Except these you are defining content type not creating content type.
1.2. use Schema Development
The Content Type Definition Schema defines the structure of the XML that creates a content
type in the element manifest file of a Feature.
<Elements Element (ContentType)>
<ContentType Element (ContentType)>
<Folder Element (ContentType) />
<FieldRefs Element (ContentType)>
<FieldRef Element (ContentType)>
<RemoveFieldRef Element (ContentType)>
<XmlDocuments Element (ContentType)>
<XmlDocument Element (ContentType)>
<DocumentTemplate Element (ContentType)>
1.3. create content types using Object Model
SPWeb..> SPContentTypeCollection....> new SPContentType object....> Add(SPContentType) method of the SPContentTypeCollection
Create site columns.
A. Introduction to Columns A site column is a reusable column definition, or template, that you can assign to
multiple lists across multiple SharePoint sites. Column Properties:
1. Name The column name must be unique among all column groups at the scope at
which you create it.
2. Data type for example, single or multiple lines of text, number, currency, date and
time, or calculation.
3. Detailed optional settings any other optional settings to apply for the data type
you selected.
4. Column group to which this column belongs user-defined groups that help you
organize your columns into logical categories. Unlike content types, you cannot create a site column based on another site column.
B. Updating Site Columns write code that updates the site column, and then call the Update method. SharePoint Foundation never writes changes made to a site column back to the site
column definition itself. Instead,it stores updates made to site columns as entries within the SharePoint Foundation database.
C. Fields and Field ReferencesSite Columns and List Columns are represented as either Field or FieldRef Element Field elements ..............>> in site and list definitions (schemas). FieldRef elements ......>> in content type definitions (schemas).You cannot create a column in a content type; you must create the column and then reference it in the content type definition.
D. Enforcing Uniqueness in Column Values New feature called unique column constraints, As stated. a column that enforces a uniqueness constraint must be indexed.
SPField custPhone = custList.Fields["Phone Number"]; custPhone.Indexed = true; custPhone.EnforceUniqueValues = true;
custPhone.Update();E. Lookups and List Relationships
Chapter 4 of 82
A lookup field is a field that is configured to get its value from a field in another list, When users create a new item, they do not type a value for the lookup column. Instead, they select a value from a drop-down list of the values in the column on the other list.
The SPList class has a GetRelatedFields method that you can use to discover lookup fields that point to a list.
List Relationships and Data Integrity: When you create or edit a lookup column through the user interface, you have the option to Enforce relationship behavior. If you select this option, you can then select either Restrict delete (Prevent Delete)or Cascade delete(Delete Related Field).
For SharePoint Foundation to either restrict or cascade deletions, the lookup field must be indexed.
A side-effect of choosing either to cascade or to restrict deletions is that the values of lookup fields are validated when they are set.
Creating Multiple-Column Lookups: create multiple-column lookups to the same lookup list.
// Create the primary column.
List.Fields.AddLookup(,,)
// Create the secondary columns.
List.Fields.AddDependentLookup(,,) Discovering List Relationships:
You can discover which fields in related lists depend on information in a lookup list by calling
the GetRelatedFields method on an SPList object that represents the lookup list. The method
returns a collection of SPRelatedField objects.
Content type inheritance:
SPContentType class //Represents a site or list content type.
public sealed class SPContentType
Where a content type is used as the basis for another content type
SPContentTypeUsage class: //Used to track where a content type is used as the basis
for another content type.
GetUsages(SPContentType) method, which returns a generic list of
SPContentTypeUsage objects.
1.4. ContentTypeBinding Element:
Specifies a content type to provision on a list defined in the onet.xml schema.
Lists defined in the onet.xml schema cannot be modified directly.
Manage content type behaviors
Manage event receivers
The SharePoint Foundation event model is built upon a common set of components and
concepts, which are summarized in the remaining sections:1. Before and After Events:
a) Before events “ing” are always synchronous.
b) After events “ed” execute in a different process from the triggering action, they
can execute either synchronously or asynchronously.2. Event Hosts: are objects, such as site collections, Webs, lists and list items, that expect
to receive events – or, in other words, objects whose event receivers “listen” for
SharePoint Foundation events.3. Event Receivers and Handling Events:
Event handler code is compiled into a .dll file and deployed to the GAC.
Chapter 5 of 82
i. create a new project of type "class library" and then inherit from one of the event
receiver base classes.
ii. override wanted methods
iii. Binding ....774. Binding Event Handlers: “register” or binding is the process by which event handler code
is associated with an object type by two ways:
a) Declarative XML within a SharePoint Feature, either by list type or by content
type, When you define a content type with a feature, you create two XML files:
1. Feature.xml: Define the metadata for the new feature.
2. Elements.xml: Define the assembly that encapsulates the event
handler, the class itself, and also a sequence number that specifies the
order, if multiple event handlers are associated with the Feature.
b) Code that implements classes in the SharePoint object model. SPList list = web.Lists["Shared Documents"];
SPEventReceiverDefinition def = list.EventReceivers.Add();
def.Assembly = "ERDefinition, Version=1.0.0.0, Culture=Neutral,
PublicKeyToken=704f58d28567dc00";
def.Class = "ERDefinition.ItemEvents";
def.Name = "ItemAdded Event";
def.Type = SPEventReceiverType.ItemAdded;
def.SequenceNumber = 1000;
def.Synchronization = SPEventReceiverSynchronization.Synchronous;
def.Update();5. Event Troubleshooting:
a) The event behaviors has some issues should solved for events to work correctly
manage workflow associations
public SPWorkflowAssociationCollection WorkflowAssociations { get; }
SPContentType.WorkflowAssociations property: Gets an
SPWorkflowAssociationCollection object that represents the workflow associations for
this content type.
You can test for the existence of a workflow association in the content type’s collection
by calling the GetAssociationByName method. If the return value of that method is not a
null reference
manage policies
1. An information management policy is a set of rules that govern the availability and
behavior of a certain type of important content.
2. Policies provide the following benefits:
1. Administrators can set and manage "the rules" for a content type from a
single location, including both client-side policy features and server-side policy
features.
2. Policies are tightly coupled to the content.
3. Policies require little involvement from end users, because corporate
policies are automatically and transparently followed.
3. Policy Architecture
each policy is a collection of instruction sets for one or more policy features. Each policy
feature provides a specific kind of content management functionality. You can assign a
policy to a content type or to a list.
Chapter 6 of 82
4. You can assign only one policy to a given content type or SharePoint list. However, that
policy can contain any number of policy items.
manage document templates
DocumentTemplate Element (ContentType): Specifies the document template for the
content type. This is the file which SharePoint Foundation opens as a template when a
user requests a new item of this content type.
1.5. Managing Document Templates with Content Types and Content Type Hub:
If you are working on a hub site that publishes content types to other site collections, you can:
a) Publish content types to make them available for use on subscribing sites.
b) Republish content types so that subscribing sites can receive updates.
c) Unpublish content types.
You have to run stsadm command to see the Content type publishing option appear in Site
Collection Administration
1.6. Deploy a content type across a number of site collections:
1. Using content publishing: Setup the content type hub then Create a feature that
contains a content type with a document template, and the document template itself
then Deploy the feature to the farm, finally activate the feature on the content type
publishing hub site collection.
2. Without using content publishing: using a site scoped feature then the _layouts
approach is the only solution to make it easy by using a library to contain the
templates Document templates need to be stored either in the 1- site collection
where the content type is defined, or 2- in <SharePoint root>/Templates/Layouts
(_layouts).
1.7. Deploying a Document Template file in Content Type in a (Office365) Sandboxed Solution:
SP Root folder “15” is not accessible in Sandboxed solutions and hence it is not possible to
deploy the document templates in _layouts folder, You will need to include the document
template within SharePoint, meaning it will be stored in the content database.
Steps:
1. Create and Configure a Module: In this step, you create a feature manifest file
that contains a Module element. This specifies which files to deploy and where to
deploy them.
2. Add the Module to a Feature: In this step, you create a feature and add your
feature manifest file to the feature. This enables you to deploy the module to the
SharePoint environment.
Solution:
a) Add the Templates module under your content type and delete the default files
Sample.txt and Elements.xml added.
b) Edit the content type Elements.xml and add the Module definition just before
declaring the content type.
c) update the DocumentTemplate reference in the content type definition.
d) Deploy and test your solution.
Implement site provisioning
Create site definitions
A site definition defines a unique type of Microsoft SharePoint Foundation website.
To create a custom site definition with one or more configurations, follow the procedures:
Chapter 7 of 82
Declarative task no code used
Adding (CAML) markup to two critical files: a WebTemp*.xml file and an Onet.xml
file.
May create one or more custom site pages.
For globalization, you can also use of one or more resource (.resx) files.
do not edit the original WebTemp.xml file. Instead, create a custom WebTemp*.xml file
WebTemp.xml you are creating will be merged with the built-in file. Do not change
the built-in file. The name of your custom file must match the pattern WebTemp*.xml.
Configuration: Specifies the set of lists, Features, and modules that are included when
a site is created.
Modifying site definition:
1. SharePoint Designer :Modify site definition files to customize existing sites or lists
is not supported.
2. Object model to modify sites after they are created.
Four site definitions whose configurations can be used to create new websites.
1. STS includes configurations for, Blank Site, Team Site, and Document Workspace.
2. MPS includes configurations for Basic Meeting Workspace, Blank Meeting Workspace, Decision Meeting Workspace, Social Meeting Workspace, and Multipage Meeting Workspace.
3. BLOG provides a site definition configuration for blogs.4. SGS provides a site definition configuration for Group Work Site.
Core Schema Files:
WebTemp*.xml Files: Identify the site definitions, configurations and appearnce in
the user interface (UI).
Onet.xml Files: Define the navigation areas, specify document templates and their
files, define the base types for lists, and define configurations and modules for site
definitions.
Each of these XML files uses (CAML) to define various aspects of a site.
create web templates
created by two ways:
1. UI: When a user customizes a website in the (UI) or Microsoft SharePoint Designer, and
then saves the website as a template, a web template is created, and stored in the
Solutions Gallery of the top-level site in a site collection, where they become available
for subsite creation on all websites in the site collection.2. Code: by create new project Import SharePoint Solution Package project as
sandboxed solution, then Download the solution (.wsp) file from the Solution Gallery and point to it as the project source, finally edit the files as needed (WebTemplate element, Onet.xml file,...).
A web template is persisted in the SharePoint database as a Solution, which is a file .wsp
extension, a .wsp file is actually a .cab file (library of compressed files stored as a single
file).
Web templates can be downloaded, edited, and redeployed as a sandboxed solution to other
site collections.
Easy to create, are easy to Deploy, modified without affecting the sites that have been
created.
implement feature stapling “Feature/Site Template Association”
Chapter 8 of 82
allow you to associate new Features and functionality with existing site definition configurations
Two Features are involved in a Feature/site template association:
1. the Feature containing the functionality you want to add to an existing site definition
configuration.
2. The Feature/site template association.
Possible scopes:
a) Farm: Yes
b) Web Application: Yes
c) Site Collection: Yes
d) Web Site: No
implement custom provisioning code
public abstract class SPWebProvisioningProvider ( )
//Provides a handler for responding to Web site creation.
use ApplyWebTemplate method
Chapter 9 of 82
Chapter 2 Implement authorization and authentication (10‒15%)
Implement user authentication
Create a custom claims provider
Introduction to Creating Custom Claims Providers in SharePoint There is two security models:
A. Classic Mode: older versionB. Claims Mode: new model
When a web application that runs in Claims Mode authenticates a user, it creates a security token for the user by using Security Assertion Markup Language (SAML).
What is powerful about creating a custom claims provider is that your code is called each time the hosting web application authenticates the user and creates a SAML token. Your code is then given the opportunity to do the following:
1) Determine who the user is.2) Query for information about the user.3) Add claims about the user into the resulting SAML token.4) A custom claims provider supplies an important point of interaction for SharePoint
site administrators who are configuring permissions on lists and sites. Two Types of claims providers:
a) People picker claims provider:enable a user to search and resolve entities in the standard people editor controls provided by SharePoint Foundation.
b) Claims augmentation provider:Used to augment the claims (such as attributes) of a user. For example, can add custom claims to a user's security token, which provides more flexibility when you configure permissions on sites, lists, items, and documents.
Code: Add new class that inherits from SPClaimProvider, add a public constructor that takes a
single string parameter and passes it to the base class constructor. class AudienceClaimProvider : SPClaimProvider {
public AudienceClaimProvider(string displayName): base(displayName) {} }
Define one or more claim types. A claim type is identified by a unique string, and by URI
A claims provider requires a name and a description for registration internal const string.
SPClaimProvider has several methods and properties that you must override. bring the claims provider to life, using two methods FillClaimTypes and
FillClaimValueTypes , FillEntityTypes. Adds claims to the user's SAML token. implement the methods of the SPClaimProvider class that interact with the People
Picker page: FillSearch : search in the People Picker page, creates a picker entity object for each audience match by using a utility method named CreatePickerEntityForAudience,
Conclusion
The ability to create custom claims providers for Microsoft SharePoint, enables you to move
beyond simple security schemes where permissions can be configured only in terms of user
account names and groups. By adding custom claims into the SAML security tokens of your
users, you can make it possible for site administrators to configure security permissions in
terms of new abstractions—such as Users Over 21, Naturalized United States Citizens,
Managing Partners.. .
Chapter 1 of 82
package and deploy a custom claims provider
SPClaimProviderFeatureReceiver class:
Defines a class for provisioning and unprovisioning a single claim provider. [SharePointPermissionAttribute(SecurityAction.Demand, ObjectModel = true)] public abstract class SPClaimProviderFeatureReceiver : SPFeatureReceiver
create a custom membership provider &package and deploy a custom membership provider
Claims Walkthrough:
Learn how to create forms-based authentication for claims-based web applications by using a
custom membership and role provider as the authentication provider..
Overview of Authenticating Claims-Based Web Applications by Using Custom Membership and
Role Providers
1: Reviewing the Membership and Role Provider Code
2: Building and Deploying the Membership and Role Provider
3: Creating a SharePoint Web Application
4: Configuring the Membership and Role Provider for the SharePoint Web Application
5: Testing Forms-Based Authentication
6: Viewing Claims
Conclusion: Forms-based authentication provides custom identity management
create a custom sign-in page with Forms Based Authentication.
Configure Forms Based Authentication in SharePoint
Create a New SharePoint Application choose “Claims Based Authentication” for the
Authentication type, create the site collection.
Enable and configure the forms based authentication settings.
1) Create the database using aspnet_regsql
2) Add users and roles using the Web Site Administration Tool
3) Add connection strings in the web.config for:
Your application
Central Administration
Secure Token Service Application
4) Add membership and role providers for:
Your application
Central Administration
Secure Token Service Application
5) Edit web.config for Central Administration
Set the default provider for roles as AspNetWindowsTokenRoleProvider
Set the default provider for membership as your new membership provider
Add the PeoplePickerWildcards entry
6) Edit web.config for the Secure Token Service Application
Set the default provider for roles as your provider
Set the default provider for membership as your provider
7) Add the FBA administration user to Central Administration
8) Add FBA roles to SharePoint groups
Creating a Login Page:
A. Create new Empty SharePoint Project.
B. Choose Farm Solution.
C. Add a new item to the project “Application Page”.
D. Add a reference to the assembly “Microsoft.SharePoint.IdentityModel”.
Chapter 2 of 82
E. Update the markup for the page.
F. Create the code-behind for the page.
G. Inherit from FormsSignInPage
Configure your custom login page:
1. In Central Administration, click on “Manage web applications”.
2. Click your web site. Then click the “Authentication Providers” ribbon button.
3. Finally choose the zone that you want to configure, enter Sign In Page URL.
authenticate a user from a client application
The 3 Object Models with their available authentication methods are:
1. .NET Client Object modelo The default is to authenticate users via their current Windows credentials (NTLM and
Kerberos).o Possible for you to define other authentication methods like Anonymous or Forms
Authentication.
2. Silverlight Client Object modelo Default is to authenticate users via their current Windows credentials (NTLM and
Kerberos).o It is possible for you to define other authentication methods like Forms Authentication.
o It is not possible to use the Silverlight client object model with anonymous
authentication.
3. ECMA Script Client Object modelo No need for additional authentication as JavaScript already runs in an authenticated
page.
ClientContext clientContext = new ClientContext("http://ltp-21:31890");
//Set the AuthenticationMode
clientContext.AuthenticationMode = ClientAuthenticationMode.FormsAuthentication;
//Instantiate a FormsAuthenticationLoginInfo object.
FormsAuthenticationLoginInfo formsAuthInfo = new
FormsAuthenticationLoginInfo("MyFormsTestUser", "MyUserPassword!2");
//Specify the login details using the FormsAuthenticationLoginInfo object.
clientContext.FormsAuthenticationLoginInfo = formsAuthInfo;
Web site = clientContext.Web;
clientContext.Load(site);
clientContext.ExecuteQuery();
Console.WriteLine("Title: {0}", site.Title);
Using the Client Object Model with a Claims Based Auth Site:
1.1. What's new in SharePoint 2013 for authentication, authorization, and security?A. User sign-in:
SharePoint 2013 continues to offer support for both claims and classic authentication modes.
Claims authentication is the default authentication option in SharePoint 2013. Classic-mode authentication is deprecated and can be managed only by using
PowerShell. The MigrateUsers method from SharePoint 2010 is now deprecated, it's no longer
the correct way to migrate accounts. To Migrate accounts from classic-mode in SP2010 to claims-based authentication in SharePoint 2013, use the new Windows PowerShell cmdlet called Convert-SPWebApplication.
Chapter 3 of 82
Requirement to register claims providers is eliminated. However, you do have to pre-configure claims type.
SharePoint 2013 tracks FedAuth cookies in the new distributed cache service using Windows Server AppFabric Caching.
Significantly more logging is provided to help troubleshoot authentication issues.B. Services and app authentication:
A app for SharePoint has its own identity and is associated with a security principal, called an app principal. Like users and groups, an app principal has certain permissions and rights.
In SharePoint 2013, the server-to-server security token service (STS) provides access tokens for STS authentication. The STS enables temporary access tokens to access other application services, such as Exchange Server 2013 and Microsoft Lync 2013, and apps for SharePoint 2013.
Authentication and authorization
SharePoint 2013 supports security for user access at the website, list, list or library folder, and item levels, making it easier to manage user rights and group rights throughout a website.
Authorization: which users can perform specific actions on a given object. Authentication: Windows authentication or non-Windows authentication. Windows authentication: allows IIS to perform the authentication for SharePoint
2013, supporting all (IIS) and Windows authentication integration options, including
Basic, Digest, Certificates, Windows NT LAN Manager (NTLM), and Kerberos.
ASP.NET Forms: A non-Windows identity management system that uses the ASP.NET forms-based authentication system.
Claims-based identity and authentication
Claims-based identity is an identity model in SharePoint 2013 that includes features such as authentication across users of Windows-based systems and systems that are not Windows-based, multiple authentication types, stronger real-time authentication, a wider set of principal types, and delegation of user identity between applications, supporting The following sign-in or access modes:a) Windows claims–mode sign-in (default)b) SAML passive sign-in modec) ASP.NET membership and role passive sign-ind) Windows classic–mode sign-in (deprecated in this release)
Single sign-on is much easier to achieve, and your application is not responsible for the following:i. Authenticating usersii. Storing user accounts and passwordsiii. Calling to enterprise directories to look up user identity detailsiv. Integrating with identity systems from other platforms or companies
Forms-based authentication
provides custom identity management in SharePoint 2013 by implementing: a
a) Membership provider, defines interfaces for identifying and authenticating individual users.
b) Role manager, which defines interfaces for grouping individual users into logical groups or roles.
The membership provider validating the credential information by using the System.Web.Security.Membership.ValidateUser method
The role manager is optional. If a custom authentication system does not support groups, a role manager is not necessary.
Chapter 4 of 82
SharePoint 2013 supports one membership provider and one role manager per URL zone.
The ASP.NET forms roles have no inherent rights associated with them. Instead, SharePoint 2013 assigns rights to the forms roles through its policies and authorization.
In ASP.NET membership and role passive sign-in, the sign-in happens by redirecting the client to a web page where the ASP.NET log-in controls are hosted. After the identity object that represents a user identity is created, SharePoint 2013 converts it to a ClaimsIdentity object (which represents a claims-based representation of a user).
Implement application authentication and authorization
Use the SharePoint App TokenHelper class
Authorization, users, groups, and the object model in SharePoint 2013
1) Introduction
i) Access to SharePoint 2013 objects is controlled through a role-based membership
system by which users are assigned to roles that authorize their access to SharePoint 2013
objects.ii) Groups consist of users and may or may not be assigned to roles. SharePoint 2013
includes the following three groups by default: owners (administrator) members (contributor) visitors (reader)
2) Security policy
provides a way to enforce uniform security throughout all site collections within a web
application
In policy roles, the users and groups are identified by both their security identifier (SID)
and their login or user name.
Central administration policy roles differ from the role definitions for a site collection.3) Users, groups, and principals
user (SPUser) gains access to a SharePoint object two ways:
I. directly through an individual role assignment, ..> the user is the principal
II. indirectly through membership in either a domain group or a SharePoint group
(SPGroup) that has a role assignment, ...> the domain group or SharePoint group is the
principal
user-based permissions management through two ways:
1) access control lists (ACLs) for small number of users.
2) Group-based for larger number of users.
SharePoint Server groups supports two kinds of: i. Domain groups: remain outside SharePoint Server control; users cannot use
SharePoint Server to define, browse, or modify domain group membership, Domain
groups can be used anywhere within the scope of the Active Directory directory service.
ii. SharePoint groups: are scoped to the site-collection level, and they can be used only
within the site collection.
Principal is a user or group that is used to control security:
A. If you add a user to a site, the user is the principal, but
B. if you add a group to the site, the group is the principal.
Chapter 5 of 82
By using groups, a smaller number of principals can be used to grant access to a much larger
number of users.4) High-level view of object relations—scopes, users, groups, and roles
A scope represents a uniquely
secured object or set of objects.
[site, list, folder or item level]
Users groups (N : N):Each
user (SPUser) can be a member
of multiple groups, and each
group (SPGroup) can contain
multiple users.
Rights and role definitions (N
to N):
Right”insert list item ” can be in multi role defnitions [Contributor, Designer, and
Administrator]
Role definition “Contributor” can also
contain multiple rights. [inserting,
updating, and deleting list items].5) User tokens and access control lists
To make checking permissions faster, SharePoint Server implements user tokens and
ACLs in its security model.
The user token identifies the authentication process applied to a user.
ACL is a binary object that determines the rights that users and groups have on a given
object.
An ACL consists of multiple ACEs, each security principal (user or group) being one ACE
in the ACL6) Object model changes: obsolete but backward-compatible security objects
The following security objects used in WSS 2.0 are obsolete, but continue to function:
I. Microsoft.SharePoint.SPPermission
II. SPPermissionCollection
III. SPRights
IV. SPRole
V. SPRoleCollection
Replaced by:
i) SPBasePermissions “Right”
ii) SPRoleDefinition “RoleDefinition”
iii) SPRoleAssignment “RoleAssignment”7) Guest roles (Limited Access) to accommodate shared resources
The concept of a guest role is extended to include folder-level permissions and list-level permissions.
When a user is granted permissions on a folder, they are also granted the Guest role on the parent list of that folder and on the parent website
8) Removing users from a scope or from all scopes
The only way to remove a user from all scopes is to delete that user from the site collection, which removes the user from all roles in all scopes within the site collection.
1.2. Use the SharePoint App TokenHelper class,
Chapter 6 of 82
App authentication in SharePoint
i. The authentication process verifies a claim that is made by a subject (in this case, an app)
that it should be allowed to act on behalf of a given principal (in this case, an authenticated
SharePoint user)
Authorization policies:
The authorization process verifies that an authenticated subject (an app or a user or both)
has permission to perform certain operations or to access specific resources
three types of authorization policies:
a) User-only policy .In SP2010 content database authorization checks succeed if user has
permissions
b) App-only policy , Ex:expense submission app. if App has
permissions
c) User + app policy . App Part “iframe” if user +App
permissions
App permissions and app permission request scopes
App developer should specify through the app manifest file, the permissions an app needs to
SharePoint resources outside the app web.
OAuth 2.0 in SharePoint 2013:
OAuth 2.0 is an open framework for authorization.
OAuth enables secure authorization from desktop and web applications in a simple and
standard way.
OAuth enables a user to approve an application to act on his or her behalf without sharing his
or her user name and password.
For example, user can share private resources (documents, photos, videos and so on) on one
site with another site, without requiring credentials (typically user name and password).
OAuth enables users to provide access tokens, instead of credentials, Each token grants
access to a specific resource provider (website) for specific resources (ex:documents in a
SharePoint document library) and for a defined duration (ex:12 hours)
A typical apps for SharePoint scenario is as follows:
1) A user signs in to SharePoint and is authenticated.
2) The authenticated user then installs an app for SharePoint from either the Office Store or the
app catalog.
3) The app is granted permission by the user to access SharePoint resources.
4) When an authenticated user (not necessarily the same one who installed the app) launches
the app, SharePoint POSTs a context token to the app.
5) The app then calls back to SharePoint to access the SharePoint resources on behalf of the user
by using an access token.
When is OAuth used?
i. If you plan to build an app for SharePoint that runs in an remote web application and
communicates back to SharePoint using server-side code.
Remote Web application:
Off premise: use the ACS authorization system in which ACS is the token issuer.
On premise: use the high-trust system in which the app itself and a digital
certificate are the token issuers.
ii. The OAuth 2.0 framework uses token passing "flows" to:a) Authorize requests by an app for SharePoint to access SharePoint resources.b) Authenticate apps in the Office Store, an app catalog, or a developer tenant.
When is OAuth not used?
When make a call from the app web itself or from JavaScript a remote webpage using
the cross-domain library.
Access tokens:
Chapter 7 of 82
To access resources, an app has to request an access token from an OAuth security token
service (STS)
In contrast, the WS-Federation STS and the Security Assertion Markup Language (SAML)
passive sign-in STS are primarily intended to issue sign-in tokens.
An example of an OAuth STS is Microsoft Azure Access Control Service (ACS).
OAuth STS is not used for issuing sign-in tokens, that is, they are not used as identity
providers. So, you will not see an OAuth STS listed in the user sign-in page, the
Authentication Provider section in Central Administration, or the people picker in
SharePoint.
specify the App permission request scope manifest and permission request manifest:
Certain APIs require a user context and can't be executed with an app-only policy.
Apps that do not make OAuth authenticated calls (for example, apps that are only JavaScript
running in the app web) cannot use the app-only policy. They can request the permission, but
they will not be able to take advantage of it because doing so requires passing an app-only
OAuth token. Only apps with web applications running outside of SharePoint can create and
pass app-only tokens.
OAuth and server-to-server calls should use the app-only policy if: The app needs to elevate its permissions above the user for a specific call (for example, to
approve an expense report under conditions evaluated by the app). The app is not acting on behalf of any user (for example, the call is being made by the app
alone, not by a user who is using the app).App permissions in SharePoint 2013
i. Introduction:An app has the following basic information:
Client Id. Display name. The app domain.
ii. Types of app permissions and app permission request scopes: The permission requests specify both the rights that an app needs and the scope at
which it needs the rights. Types of app permisson: Permission request scopes indicate the location in the SharePoint hierarchy where a
permission request applies. SharePoint 2013 supports scopes within the content database and tenancy:
1) site collection2) website3) list4) Tenancy
If an app is granted permission to one of the scopes, the permission applies to all children of the scope.
Because permission requests are made without information about the topology of the site collection where the app is installed, the scope is expressed as a type instead of as the URL
iii. Understanding differences between app permission rights and user rights App can have the following rights:
a) Read: Enables apps to view pages, list items, and download documents.b) Write: view, add, update, and delete items in existing lists and document libraries.c) Manage: view, add, update, delete, approve, and customize items or pages
within a web site.
Chapter 8 of 82
d) FullControl:Enables apps to have full control within the specified scope.e) Query right For Search only.
These rights correspond to the default user permission levels: Reader, Contributor, Designer, and Full Control.
Unlike SharePoint user roles, these rights levels are not customizable. App rights names do not match the corresponding SharePoint user roles, except Full
Control, which can't be customized through the permissions management user interface. Permissions that are not known to SharePoint 2013 are ignored.
iv. Permission request scopes, available rights, and Office Store apps rights Different scopes have different sets of rights that are available for an app to request:
I. Office Store apps: Only Read, Write, and Manage rights are allowed no full control.II. site collection website list: Read, Write, Manage and full control.III. other SharePoint features:
BCS Read. Search QueryAsUserIgnoreAppPrincipal. Project Server Read, Write, Manage , SubmitStatus and Elevate. Social features Read, Write, Manage and full control. Taxonomy app Read and Write.
Apps that request more than Manage permissions can still be deployed through the app catalog as it is blocked through “office store”.
v. Managing app permissions The SharePoint 2013 implementation of the OAuth protocol, end users have four
different opportunities to manage app permissions:1) During app installation2) By using explicit permissions management3) By using an end-user consent UI4) During app removal
vi. Next steps How to: Create a basic provider-hosted app for SharePoint Tips and FAQ: OAuth and remote apps for SharePoint OAuth authentication and authorization flow for cloud-hosted apps in SharePoint
2013Plan app permissions management in SharePoint 2013
App permissions management manage the ability of apps to access and use internal SharePoint 2013 resources and perform tasks on behalf of users.
IntroductionTo plan the management of app permissions you have to:a) Determine the specific SharePoint 2013 resources that the app will need to access, and
where those resources reside.b) Determine the minimum permission level that will be required to enable the app to function
correctly. c) Determine the appropriate app authorization policy to ensure that the app functions
correctly and complies with specified authorization requirements.d) Determine who will be installing the apps and who will be using them.
App permission request scopes Specify the level at which the app is intended to run, and the permission level that is
assigned to the app. Permission request scopes:
1) SPSite Defines the app permission request scope as a SharePoint 2013 site collection.
2) SPWeb web site.
Chapter 9 of 82
3) SPList list.4) Tenancy Tenancy
App permission requests are collections of permissions that enable apps to perform specific tasks. For example Read (View Items, Open Items, View Versions, Create Alerts, View Pages).
specify permissions for Office Store apps,
Only Read, Write, and Manage rights are allowed for Office Store apps
specify permissions for Corporate Catalog Apps, specify permissions for remote apps to access SharePoint data
????????????
1.3. Build apps for SharePoint
What is an app for SharePoint in SharePoint 2013?
Is a solution that carries a light footprint and uses standards-based technologies such as
HTML5, JavaScript, and Oauth, to extend the capabilities of a SharePoint website.
light footprint because they don't actually install on the host server, and that means they
don't overload a SharePoint site with excessive API calls.
Why build apps for SharePoint?
a) A familiar programming model, plus popular technologies and languages
For apps, the web is the platform. If you can build a web application, you can build an app
for SharePoint, Use any language [HTML, JavaScript, PHP, or .NET] - and your favorite web
development tools [Visual Studio 2012 or the new "Napa" Office 365].
Have a similar development process for any device you are targeting – mobile phones,
tablets, or computers – so you can be more efficient and productive.
Separate the app’s logic data[sql,mysql,..]and user interface (UI)[JS,ASP.net,..] to fit your
needs.
Use the expanded capabilities of REST and client APIs (JavaScript and .NET) to access the rich data and services in SharePoint such as search, workflow, social networking, taxonomy, user profiles, and Business Connectivity Services (BCS).Use the new OAuth 2.0 support in SharePoint.
b) Multiple options for hosting
1. SharePoint-hosted apps
Apps where all components are hosted on either an
on-premises or Office 365 SharePoint farm.
Installed on a SharePoint 2013 website, called
the host web. They have their resources hosted on
an isolated subsite of a host web, called the app
web.
Deployed to app webs, rather than the host web for
Two Reasons:
a) Enforcement of app permissions: App has it’s permissions that are
not necessarily the same as the permissions of the user who is
executing the app.
b) Cross-domain scripting security: Ensure that JavaScript in the app for
SharePoint cannot execute any JavaScript from any other domain.
You can combine a SharePoint-hosted app with apps that have remotely hosted components,
but any app or portion of an app that runs on an app web has the following set of
requirements for three key components:
a) where the app is hosted.
Chapter 10 of 82
b) How the app gets authorization.
c) What language it can use.
Advantaged “Benifits” of SharePoint-hosted apps ?
1. Reuse common SharePoint items, like lists and Web Parts, BUT Only JavaScript no server side code
2. Easy to create and deploy, so they are good for small team productivity apps and business process automation, with lower complexity business rules, BUT Your app has only the authorization privileges of the signed-in user.
3. Learn how to create a basic SharePoint-hosted app.
2. Provider-hosted apps
Include components that are deployed and hosted outside the SharePoint farm. They are
installed to the host web, but their remote components are hosted on another server.
A provider-hosted app interacts with a SharePoint site but also uses resources and services that are located on the remote site.
Requirements three key components: a) where the app is hosted. Any web server or hosting service.b) How the app gets authorization. OAuth or the JavaScript cross-domain library.c) What language it can use. Any language supported by your web server or
hosting service.
Get these benefits But consider this Host the app on Microsoft Azure or any
remote web platform, including non-Microsoft platforms.
You are responsible for creating the installation,upgradeand uninstallation logic of the remote components.
Use one of the SharePoint client object models,
the JavaScript cross-domain library, or REST/OData-based web service to interact with SharePoint.
Each way of interacting with SharePoint has corresponding options for approaches to data access.
Gain authorization to SharePoint data using either
OAuth or the JavaScript cross-domain library.
You need to decide between OAuth and the cross-domain library to authorize your app’s access to SharePoint.
3. AutoHosted Apps
J
c) A familiar web experience, yet more flexible
Apps for SharePoint have the same user experience as SharePoint websites but are more:
1) As an immersive full-page experience
2) As part of a webpage, using app parts to surface an iframe element that contains the app
3) As UI custom actions, extending ribbons and menus by adding the app to list items, documents,
and more
Chapter 11 of 82
d) Integrates with apps for Office
Use the Office Store to sell your app for SharePoint
e) Lets you reach users through the Office Store and the App Catalog
Use the Office Store to sell your app for SharePoint to users
Apps for a company are deployed to the organization's internal App Catalog hosted on
SharePoint,
Start developing apps for SharePoint
Building an app for SharePoint
To build your app for SharePoint, you must do the following:
1) Configuring an app
An app for SharePoint is configured with SharePoint using an app manifest—an XML file that
declares the app’s basic properties, where it runs, and what to do when it starts.
An app manifest file can do many things:
A. Use different authentication schemes (app principals) and declare the permissions the app needs.
B. Can also include tokens that are replaced at build/run time, so you can reference your app and
pass context (for example, the SharePoint language and where the app is installed)
C. Tells SharePoint to register the app and invoke a remote page when the app starts.
2) Deciding where the app’s code runs (hosting options)
Host in SharePoint, in the cloud, or a mix of SharePoint and cloud.
1. Provider-hosted apps: You must host a provider-hosted app on a dedicated server or third-party hosting service. Depending on your choice, these apps run either on your server or in the cloud.
2. SharePoint-hosted apps: When the app is hosted in SharePoint itself, the code is only in HTML and JavaScript and is hosted by SharePoint.
3. Hybrid apps (components in both SharePoint and the cloud): In these apps, SharePoint components run in SharePoint while components hosted in the cloud run in the cloud.
3) Communicating with SharePoint using SharePoint APIs
Apps show their power when they use SharePoint APIs to connect and integrate with
SharePoint features—search, workflow, social networking, taxonomy, user profiles, BCS, and
more. This lets them read documents, do searches, connect people, and much more.
SharePoint APIs include the following:
i. REST APIs and JavaScript APIs
ii. Managed APIs (.NET)
4) Packaging and distributing an app
Apps for SharePoint are distributed as an app package, and the components it contains depend
on where your app is hosted.:
a. A provider-hosted app package might contain only the app manifest if the app is hosted
on a dedicated server or third-party hosting service.
b. A SharePoint-hosted app package might contain some SharePoint-related components
and the app manifest.,App packages can include components such as apps for Office.
Plan and implement user authorization
Chapter 12 of 82
Create custom role definitions, create custom permission levels, maintain permissions:
SPRoleDefinition class:public sealed class SPRoleDefinition
Defines a single role definition, including a name, description, management properties, and a
set of rights.
There is not a method to retrieve user role assignments on a SharePoint Foundation list object,
but by code:SPRoleAssignmentCollectionforeach (SPRoleAssignment oRoleAssignment in oRoleAssignments) { SPPrincipal oPrincipal = oRoleAssignment.Member; try { // Retrieve users having explicit permissions on the list SPUser oRoleUser = (SPUser)oPrincipal; }
SPRoleAssignment classpublic sealed class SPRoleAssignment
Defines the role assignments for a user or group on the current object.
To grant a user or group permission to securable content:
1) Create a role assignment object
2) set the user or group for the role assignment
3) add the appropriate role definitions
4) add the object to the collection of role assignments for the securable object.
implement impersonation:
Impersonation, a feature that was added in Windows SharePoint Services 3.0, enables you to
perform actions on behalf of another user.
To continue working with objects on a site after performing an impersonation action in code, you
must reinstantiate the SPSite object.
Managing User Tokens
SharePoint fetches user token information from the SharePoint database.
If the user account is an NT account, SharePoint uses the AuthZ interface to query the
Active Directory for the TokenGroups property.
If the user account is a membership user, SharePoint queries the ASP.NET RoleManager for
all the roles that the user belongs to.
implement anonymous access, create a custom role manager:
how enable annoymous access:
A. Central Administration.
B. Application Management, click on the Manage web applications,choose webapp.
C. click Authentication Providers ribbon button.
D. click the Default zone. And then show the Edit Authentication dialog box.
E. check Enable anonymous access and click save.
Chapter 13 of 82
Chapter 3 Access and manage data (10‒15%)
Design solutions to handle large amounts of data
Create efficient CAML (Collaborative Application Markup Language )queries and views
Query Schema:
The Query schema of (CAML) is used in various ways within the context of Microsoft SharePoint
Foundation to define queries against list data.
Assign CAML query strings to :
i. Query property of several classes in the server and client object models in order to return data,
or
ii. Method parameters of the Lists web service to work remotely with data.
iii. Context of CAML views to return specific data.
View Schema:
The View schema of (CAML) is used to define how the contents of a list view are rendered in
Microsoft SharePoint Foundation.
SharePoint Foundation uses XSLT to define list views(includes a query that returns the data that is
displayed in view)
Views can be created or modified programmatically through either the server-side or client-side
object model.
Specialized rendering elements are used within a view to define the logic for constructing HTML.
Handling Large Folders and Lists: When the size of folders and lists increases, you must
optimize performance.
You should concern :
1. Query throttling, which can cause code to change in unexpected and unpredictable ways over time
as your site evolves and your queries begin to return items that exceed the query threshold.
2. Efficient retrieval of items from large folders and lists.
To view and increase this threshold or to enable the object model to override the threshold
On the Central Administration site, under Application Management, click Manage
Web Applications.
Click General Settings, and then click Resource Throttling.
View and update the threshold or allow the object model to override the limit.
When you are working with folders and lists:
Do not use SPList.Items.
SPList.Items selects all items from all subfolders, including all fields in the list. Use the following
alternatives for each use case:
Adding an item:
Instead of calling SPList.Items.Add, use SPList.AddItem.
Retrieving all items in a list:
Instead of using SPList.Items, use SPList.GetItems(SPQuery query) .
Apply filters, if appropriate, and specify only the fields you need to make the query more efficient.
Getting items by identifier
Instead of using SPList.Items.GetItemById, use SPList.GetItemById(int id, string
field1, params string[] fields). Specify the item identifier and the field that you want.
Do not enumerate entire SPList.Items collections or SPFolder.Files collections. Table 1. Alternatives to enumerate SPList.Items
Poor Performing Methods Better Performing Alternatives
SPList.Items.Count SPList.ItemCount
Chapter 1 of 82
SPList.Items.GetItemById(System.Int32) SPList.GetItemById(System.Int32)
When you delete multiple versions of a list item, use the DeleteByID() method; do not use the
Delete() method.
Choose appropriate APIs
Types of APIs including:
1) Server object model.
2) Various client object models.[ JavaScript, .NET Framework, Mobile, .. ]
3) REST/OData web service. Factors that determine which API set to use
a) The type of application: A. an app for SharePoint.B. Web Part on a SharePoint page.C. JavaScript running in a SharePoint site page.D. Application page.......
b) Your existing skills: Using any of the following programming models: 1. JavaScript2. ASP.NET3. REST/OData4. .NET Framework5. Windows Phone6. Windows PowerShell
c) The device on which the code runs: a) Server in the SharePoint farm.b) External server such as a server in the cloud.c) Client computer.d) Mobile device.
If you want to do this ... ... use these APIs
Create an HTML/JavaScript application that performs CRUD operations on SharePoint data or
Create an app for Office that works with SharePoint
JavaScript client object model
Create a custom Web Part, application page, or ASP.NET user control or Create a timer job
Server object model
Create a LAMP web application that performs CRUD operations on SharePoint data or external data that is surfaced in SharePoint by a BCS external content type or
Create an iOS or Android app that performs CRUD operations on SharePoint data
REST/OData endpoints
Server object model
The largest set of APIs is in the server object model of managed classes.
classes are added SP2013 to enable programming of:
Enterprise Content Management (ECM).
User profiles.
Taxonomy.
Advanced search.
Limitations of server object model:
You cannot use the server object model in an app for SharePoint, Client object models:
Client object models in SharePoint 2013:
Chapter 2 of 82
1) .NET: Are sent to the SharePoint server in batches where they are converted to server-side
code and executed.
Developer determine whether a batch runs Synchronously or Asynchronously.
Synchronous batch: the .NET Framework application waits for the returned results from the
server .
Asynchronous batch: client-side processing continues immediately and the client (UI) remains
responsive.
2) Silverlight: Silverlight .xap files can be included in apps for SharePoint, including SharePoint-
hosted apps.
3) Mobile. JavaScript object model
Use in either inline script or separate .js files. It includes all the same functionality as the Silverlight client object models. and .NET
Framework . In addition, it is now possible to access SharePoint data across domains in JavaScript (but only
data that is within the same parent site collection), which was not allowed in previous versions of SharePoint. Data is returned from the server in JavaScript Object Notation (JSON).
The JavaScript object model is defined in a set of *.js files located at 15\TEMPLATE\LAYOUTS on each server.
REST/OData endpoints
Representational State Transfer (REST) web service that uses the OData protocol to perform
CRUD operations on SharePoint list data.
Used when you need to access SharePoint entities from client technologies that do not use
JavaScript and are not built on the .NET Framework or Silverlight platforms
To use the REST capabilities, your code constructs a RESTful HTTP request to an endpoint that
corresponds to the desired client object model API.
The client.svc web service handles the HTTP request and serves a response in either Atom or
JSON format.
almost every API in the client object models has a corresponding REST endpoint. This enables
your code to interact directly with SharePoint artifacts by using any technology that supports
standard HTTP requests and responses.
Comparing REST/OData programming with client object model programming
Feature .NET
Framework or
Silverlight
object models
JavaScri
pt
object
model
REST/OData endpoints
called from a
Windows platform or
JavaScript
Object-oriented programming Yes Yes No
Batch processing Yes Yes No
APIs for conditional processing and
exception handling
Yes No No
Availability of LINQ syntax Yes No No
Combining list data from different
SharePoint web applications
Yes No Yes
Familiarity to experienced REST/OData No No Yes
Chapter 3 of 82
developers
Similarity to non-Windows programming
or JavaScript programming
No Yes Yes
Strong typing for list item fields No (except with
LINQ)
No Yes, from Windows
platform
No, from JavaScript
Leveraging jQuery, Knockout, and other
JavaScript libraries
No Yes No, from Windows
platform
Yes, from JavaScript
WCF Data Services Framework
If you prefer to use LINQ syntax in .NET Framework or Silverlight client applications, SharePoint
2013 supports WCF Data Services as a LINQ provider.
You can target either the listdata.svc (for list data only), or you can target the same client.svc
that supports the OData interface for access to all SharePoint entities in addition to list data.
Deprecated API sets
1. ASP.NET (asmx) web services.
2. Direct Remote Procedure Calls (RPC) calls to the owssvr.dll file.
Create and use indexed columns
Enforcing Uniqueness in Column Values by two ways:
a. Primary key identity (ID).
b. Unique column constraints feature.
Defining "Unique"
SharePoint Foundation evaluates column values and determines uniqueness based on its
evaluation of the values present in the column. For the evaluation, SharePoint Foundation uses the
sort order of the site (the SPWeb) to do uniqueness case-insensitive comparisons.
Supporting Unique Column Constraints
The key factor in determining whether a column supports uniqueness constraints is whether that
column can be indexed.
Furthermore, when uniqueness is enforced on a Lookup column, uniqueness is not enforced on the
projected column of the target list but rather on the ID column.
Column types that support the ability to be indexed ...> Unique: Single line of text. Choice field (but not multichoice). Number. Currency.
Column types that dont support the ability to be indexed: Multiple lines of text. Hyperlink/Picture. Custom Field Types. Calculated Field. Boolean (yes/no). Modified by.
Indexing a Column with Unique Constraints
After a column has been set to enforce uniqueness, indexing cannot be turned off for that column.
However, you can turn off indexing for that column if you first disable enforcement of uniqueness
constraints.
Setting Unique Constraints Programmatically
public bool EnforceUniqueValues { get; set; }
Chapter 4 of 82
//Gets or sets a Boolean value that specifies whether to enforce uniqueness in column values. The
default is false.
You cannot set this property to true for a built-in field or for a site column.
When you set this property to true, you should Firstly set the Indexed property to true.
Error Causes – Exceptions:
1) EnforceUniqueValues = true is set on a non-indexed field.
Message reading "The field must first be indexed to enforce unique values."
2) EnforceUniqueValues = true is set on a list that has existing duplicate values.
Message reading "This field contains duplicate values. Remove all duplicate values and try
the operation again”.
Content Migration and Unique Column Constraints
Content migration by using APIs support all types:
i. partial (selective) migrations:
Merge files from the source site collection with files on the target
Automatically account for uniqueness states
ii. full site collection migrations. by using export/import functions you must ensure that if the uniqueness property is set on the list field on the export
source, then the setting must be persisted on the import target.
Copy-To and Move-To Operations with Column Constraints
Special considerations come into play whenever you copy or move items to a document library
that is enforcing unique column constraints and you use
the CopyTo(String)and MoveTo(String) methods on the SPFile class
Copy To operation Move To operation
Within Same
Doc Library
Checks for uniqueness violations at the
document level.
Does not check across library folders.
Moves without checking.
Across Doc
Libraries
Converts values to null. Blocks the move if the destination list has
enforced unique values.
Out of Doc
Library
No effect. No effect.
Into Doc Library Convert values to null. Convert values to null.
Use Object Model Overrides
SPQuery.QueryThrottleMode property
//Gets or sets a value that indicates the throttling mode to be applied to the query.
public SPQueryThrottleOption QueryThrottleMode { get; set; }
Throttling is applied based on user role and permissions.
SPWebApplication.AllowOMCodeOverrideThrottleSettings property
//Indicates whether custom object model code can override the throttle settings.
public bool AllowOMCodeOverrideThrottleSettings { get; set; }
true if custom code can override throttle settings; otherwise, false.
SecurityException: The current user is not a farm administrator.
SPList.EnableThrottling property // is bad
//Indicates whether throttling for this list is enabled or not.
public bool EnableThrottling { get; set; }
A Boolean indicating throttling status. A value of true throttling is enabled while false indicates
otherwise.
Chapter 5 of 82
Farm admin can set it to FALSE to make this list exception for throttle feature if it is set to false,
then this list will not be throttled.
Use Content Iterator
Writing Efficient Code in SharePoint Server
how to make the SharePoint object model work efficiently (performance, extensibility, and scalability)
Using SPQuery Objects:
Well-designed queries can help you avoid performance problems that can occur over time as the
size of your site's lists and folders increases.1) Use a bounded SPQuery object :
Specify a RowLimit between 1 and 2000 and page through the list if necessary. 2) Limit the result set:
Set the query threshold to limit the result default is 5,000 items, 3) Use indexed fields :
SetSPQuery.RowLimit to a value that is less than or equal to the threshold value.4) Ensure you include one of the three OrderBy :
OrderByID, OrderByPath, or OrderByNVPField. Used whenever the query is not designed to be restrictive enough to return fewer than the
maximum number of items using previous techniques .
Using PortalSiteMapProvider:
PortalSiteMapProvider provides an automatic caching infrastructure for retrieving list data. The
GetCachedListItemsByQuery method of PortalSiteMapProvider takes an SPQuery object as
a parameter, and then checks its cache to determine whether the items already exist. If they do,
the method returns the cached results. If not, it queries the list and stores the results in a cache.
This approach works especially well when you are retrieving list data that does not change
significantly over time.
Limitation of PortalSiteMapProvider:
a) Collection object cache that store data has a default size of 100 MB. You can increase the
size of this cache for each site collection on the object cache settings page for the site
collection. This memory, however, is taken from the shared memory available to the
application pool and can therefore affect the performance of other applications.
b) Cannot use it in applications based on Windows Forms.
Implement cross-site queries
SPSiteDataQuery class
Represents a query that can be performed across multiple lists in multiple Web sites in the same Web
site Collection
public sealed class SPSiteDataQuery
Specify the scope of the query by setting the Webs property. Specify the lists to participate in the
query by setting the Lists property and the fields to return by setting the ViewFields property.
Control data selection and order by setting the Query property in the same Collection.
pass the SPSiteDataQuery object to the GetSiteData(SPSiteDataQuery) method, which returns
a DataTable object containing rows of data that represent the result of the query.
Access data contained in SharePoint
Access data using server-side object model
Working with List Objects and Collections:
Objects
Chapter 6 of 82
Collections [ count, add, delete]
Indexers
Access data using client-side object model (CSOM)
Data Retrieval Overview
You can use the new client object model to retrieve properties for a specific SharePoint client object,
or to retrieve child items in a collection. The client object models do not persist data that is retrieved
locally on the client.
Performing data retrieval involves the following procedure:1. Return the context for a client request by using the
(JavaScript: ClientContext(serverRelativeUrl)).2. Use the object model to specify an object to retrieve or from which to retrieve data.3. Load the object or collection:
a) load(clientObject)) : In-place load. Object identity is retained. ClientContext.Load(clientContext.Web.Lists);
b) loadQuery(clientObjectCollection, exp) Queryable load. Query is separate from the returned results. Two steps defining the query expression, retrieving the query result. Object identity is not retained, so your code must itself maintain. var query = from list in clientContext.Web.Lists select list; var result = clientContext.LoadQuery(query);
4. Execute the query by calling the: i. ExecuteQuery() method in the .NET or Silverlight version. ........> SYNC ii. ExecuteQueryAsync(SucceededEventHandler, RequestFailedEventHandler) .....>
ASYNC In the JS. 5. When the method call to execute the query returns (either synchronously or asynchronously), you
can access the results of the query on the object from which you initiated the query.Query syntax versus method syntax
Both forms of Language-Integrated Query (LINQ) syntax--query syntax and method syntax [lambda
expressions].
Three points to keep in mind when using LINQ to query against the client object model:
1) you are using LINQ to Objects, not the LINQ to SharePoint provider.
2) When your query is designed to return a subset of items from a list, it is more efficient to use a
CAML query than a LINQ query. This is because With a CAML query, the filtering is done on the
database server.
3) Returning a subset of the lists from a web site, LINQ are more efficient.Using query strings in ECMAScript
The JavaScript methods for retrieving objects and data do not accept LINQ syntax, but you can use
a string expression to define a basic query.
Ex: clientContext.load(collList, 'Include(Title, Id)');How to retrieve objects
When list object is loaded in place, all default properties of the list can be accessed.How to update objects
Both Client object model and Server object model modification require calling update() method
however,
Client object model, changes do not take effect until the object is loaded and ExecuteQuery() or
ExecuteQueryAsync(ClientRequestSucceededEventHandler, ClientRequestFailedEventHandler)How to retrieve list items
it's most efficient to use a query in CAML use this method GetItems(CamlQuery) method
Chapter 7 of 82
How to update list items
To modify a list item you can specify the column value to change through an indexer, and just as for
other objects, call Update() (JavaScript: update()) before calling ExecuteQuery() or
ExecuteQueryAsync(Sucess,Failure).
ListItem oItem = oList.GetItemById(5);Asynchronous Processing
Both the JavaScript version of the object model and the Silverlight version:
Asynchronous processing when it modifies the (UI).
Current() property when Specify the current request context.
Access data using out-of-the-box Web Services
The Web services include methods for accessing content on a Web site [lists or document workspaces,
or search].
Whenever possible, it is recommended that you use the new client-side object model to work remotely
with SharePoint Foundation data, instead of using the legacy ASP.NET Web services.
SharePoint Foundation does not require the implementation of a particular version of SOAP. The SOAP
response in any transaction with SharePoint Foundation is managed by the .NET Framework.
Access data using REST API
Use OData query string operations to select, filter, and order the data you request from the SharePoint
REST service.:
Select fields to return
Use the $select query option to specify which fields to return for a given list, list item, or other
SharePoint object represented by an entity set. You can use $select=* to return all available fields.
If you do not specify the $select query option, the REST service returns all available fields by
default.
Request can returns projected fields from other lists and the values of lookups. To do this, specify
the field name in both the $select and $expand query options. For example:
http://server/site/_api/web/lists('guid')/items?$select=Title,Products/Name&$expand=Products/Name
Bulk expansion and selection of related items is not supported.
Select items to return
Use the $filter query option to select which items to return. OData query operators supported in the
SharePoint REST service lists the filter query comparison options and functions you can use with the
SharePoint REST service.
Query for single value lookup fields
Single value lookup fields are represented by two separate fields in the SharePoint REST service:
one field representing the actual field value, and another representing the field name.
queries against the lookup field value as you would any other fields
Query for users
In the SharePoint REST service, users are represented by the user's friendly (display) name so
construct user queries against users' friendly names.
Membership-based user queries are not supported.
Usage of the Current operator to do queries using the ID of the current user is not supported.
Query for multi-value lookup fields and users
Because multi-value lookup fields are returned as a string of multiple values, there is no way to
query for them (for example, the equivalent of an Includes element or NotIncludes element is not
supported).
Sort returned items
Use the $orderby query option to specify how to sort the items in your query return set.
Chapter 8 of 82
To sort by multiple fields, specify a comma-separated list of fields.
Ascending or descending order by appending the asc or desc keyword to your query.
Page through returned items
Use the $top and $skip query options to select a subset of the items that would otherwise be
returned by your query.
The $top option enables you to select the first n items of the return set for return
http://server/site/_api/web/lists('<guid>')/items$top=10
The $skip option enables you to skip over the specified number of items and return the rest.
When using these query options, take into account that paging in OData is ordinal.
OData query operators supported in the SharePoint REST service
Access data using a custom (WCF) service to facilitate integration with an existing application: You can create a custom web service that uses the server object model to access data.Gfg
SharePoint supports creation of both Microsoft ASP.NET and WCF custom web services, which can
be used to develop SOAP-style or RESTful web services.
Chapter 9 of 82
Although an ASP.NET web service has simpler configuration requirements, a WCF service provides
more flexible, powerful bindings that are important for advanced applications.
A WCF web service can be more complicated, because its architecture requires you to specify
complete configuration of the WCF service endpoints. This configuration information includes
endpoint addresses, a service contract, and a binding configuration
Because this kind of configuration information cannot be provided in a static form, a web.config
type of configuration cannot be used. The solution is dynamic configuration, or in WCF terms,
programmatic configuration.
At run time, the SharePoint Foundation service factory configures the appropriate endpoints for
your service automatically.
Creating and Implementing a Custom WCF Service:
Important When a web application is configured to use claims authentication, the (IIS) website is
always configured to have anonymous access turned on. Your custom SOAP and WCF endpoints
may receive requests from anonymous users If you have code in your WCF service that calls the
RunWithElevatedPrivileges method.
Store configuration data
Implement web.config:
use the SPWebConfigModification class which allows you to dynamically register entities, The
changes become effective when theSPWebService.ApplyWebConfigModifications method is called.o SPWebService service = SPWebService.ContentService;
o SPWebConfigModification myModification = new SPWebConfigModification();
o myModification.Path ,name, sequence, type, value
o service.WebConfigModifications.Add(myModification);
o service.Update();
o service.ApplyWebConfigModifications();
Removing Configuration Settings:
modsCollection.Remove(configModFound);
Implement a hierarchical data store &implement a property bag, implement SharePoint List:
Managing Application Configuration:
Configuration data is data that controls the program's logic instead of data that controls the
business or user logic. An example of configuration data is a :
Connection string to a database
Storage options that SharePoint provides for other types of data
Property Bag Schema:
An elements manifest can define a property bag for a file, folder, list item, or website.
The following is a list of the elements in the Property Bag schema.
<Elements>
<PropertyBag>
<Property>
Implement credential storage:
Chapter 10 of 82
Chapter 4 Implement SharePoint solutions (15‒20%)
Manage SharePoint Object Life Cycle
Implement Object Life Cycle management for SP Objects [SPWeb, ,SPSite]:
Best Practices: Using Disposable Windows SharePoint Services Objects to avoid retaining
the objects in memory in the Microsoft .NET Framework. Introduction :
o Why Dispose? Several of the Windows SharePoint Services objects, primarily the SPSite class and
SPWeb class are lage in memory and make pressure on the garbage collector, which does not release the object from memory in a timely manner, so
You should not rely on the garbage collector to release them from memory automatically.
Finding Incorrectly Disposed Objects: To identify the code that causes the problem, you can search in the logs for entries that
contain the allocation identifiers Coding Techniques to Ensure Object Disposal:
a) Dispose method.b) using clause.c) try, catch, and finally blocks.
SPSite Objects You should dispose of any SPSite object returned from the SPSiteCollection.Add method.
SPWeb Objects o The dispose cleanup is handled automatically by the SharePoint framework.
Other Objects That Require Disposal Use SharePoint Dispose Checker Tool.
Implement Object Life Cycle management for SPContext:
You don’t need to dispose objects coming from the SPContext but if you create child
objectfrom it dispose the child object ex: SPContext.Current.Site.OpenWeb().Dispose()
Implement Object Life Cycle management with Windows PowerShell:
o Start-SPAssignment –global
o $w = Get-SPWeb http://MyWeb
o $w | Set-SPWeb –title "Accounting"Stop-SPAssignment –global
o $gc = Start-SPAssignment
o $web = $gc | Get-SPWeb http://MyWeb
o $web | Set-SPWeb –title "Accounting"Stop-SPAssignment –Identity $gc
Upgrade solutions and features
Implement versioning of features and solutions
Every Feature has a version number that is specified in the corresponding Feature.xml file.
when you deploy a new version of a Feature, SharePoint Foundation detects that the
associated Feature instance also needs an upgrade because the instance version number is
lower than the new version number specified in the current Feature.xml file.
Chapter 1 of 82
We can make use of Version attribute on the Feature element in SharePoint
Upgrade features and solutions
SHAREPOINT 2010 FARM SOLUTIONS WILL RUN ON 2013
If you take a SharePoint 2010 farm solution (as a WSP) and install it into 2013
Upgrade Steps:
a) SUPPORT MULTIPLE VERSIONS IN ONE VISUAL STUDIO SOLUTION
b) CHANGE THE VERSION OF YOUR SOLUTION PACKAGE TO '15.0'
c) WHO MOVED THE GAC?
d) SPUTILITY.GETGENERICSETUPPATH METHOD IS OBSOLETE
e) THE _LAYOUTS VIRTUAL DIRECTORY NOW HAS A SNEAKY "15" IN IT
Upgrading Features:
Microsoft SharePoint Foundation provides new members that make it possible for you to
upgrade custom Features through versioning and declarative upgrade actions:
I. Define upgrade definitions for new Feature versions.
II. Provision a list instance as part of a Feature upgrade.
III. Create separate upgrade action sets, based on the Feature version, that remove different
sets of files.
IV. Apply settings to site collections where a particular Feature is activated.
SPSite, SPWebApplication, SPWebService [.QueryFeatures(myScope, true)]
Feature.xml Changes
The new <UpgradeActions> section in a Feature.xml file specifies upgrade actions that you can
apply to a specified Feature.
The <UpgradeActions> element can contain the following sub-elements:
<CustomUpgradeAction> — Allows you to execute custom code when a Feature instance
is being upgraded. When an action is specified in an upgrade action sequence, Microsoft
SharePoint Foundation calls the FeatureUpgrading(SPFeatureReceiverProperties, String,
IDictionary<String, String>) method synchronously with other upgrade actions, in order of
declaration.
<VersionRange> — Specifies a version range to which specified upgrade actions apply.
<ApplyElementManifests> — Adds a new element to an existing Feature. When a Feature
is upgraded, provisions all non-declarative elements that are referenced in the specified
element manifests.
<AddContentTypeField> — Adds a new field to an existing provisioned content type.
Propagates the change from the site content type to all child lists and content types within
the site.
Upgrading a Farm Solution in SharePoint
There are two ways to upgrade a farm solution:
Replacement: The old version of the solution is retracted, and optionally removed from the
farm solution store. The new version is then added to the solution store and deployed. It is not
necessary that the new solution package (.wsp file) have the same name or GUID as the old
version, however, if the old version is retracted but not removed from the solution store, then
the new version must have a different filename and GUID. This kind of upgrade must be used if
the new version of the solution differs from the installed version in any of the following ways
The new version:
a) Removes a Feature that was in the old version or adds a Feature that was not in the old
version.
b) Changes the ID of a Feature.
c) Changes the scope of a Feature.
d) Changed version of a Feature Receiver.
Chapter 2 of 82
e) Adds a new elements.xml file, removes an elements.xml file, or changes the contents of an
existing elements.xml file.
f) Adds a new Property element to a Feature.xml file, removes a Property element from a
Feature.xml file or changes the value of a Property element in a Feature.xml file.
Update:
A new version of the solution package is installed and deployed which has a different file
name but the same GUID as the old version.
the GUIDs are the same, SP automatically retracts the old version before deploying the
new version.
If there are Features in the solution, then the new and old versions have the same set of
Features and they remain activated but assemblies and certain other files in them are
updated with the versions from the new solution package.
Each time a solution is successfully upgraded, the previous version of the solution is
backed up and stored in the configuration store.
This backup is used by the solution framework in the case of an upgrade failure. Only a
single backup copy is stored per solution.
Farm administrators perform an update type of upgrade with the Update-SPSolution
command in SharePoint Management Shell.
Implement assembly versioning & Build components for in-process request routing
One of the nice features of Sharepoint 2010 is the automatic assemblies redirect which
allows to use old code which was written and compiled for Sharepoint 2007 also in
Sharepoint 2010. It is achieved by assemblies redirects in web.config.
Determine a solution structure
Select feature scope and visibility.
Elements by Scope
Define feature dependencies.
Activation Dependencies and Scope:
Expresses a requirement in the relationship between two Features. when a Feature at a
particular scope has a dependency on another Feature .
Why using activation dependencies??
a) Feature grouping concepts: When one Feature is activated, other Features can also be
activated or When you deactivate the Feature, the dependent Features are deactivated if no
other Features depend on them.
b) Feature resource guarantees: You may need Web site-scoped Feature to contain an
implementation. You can use an activation dependency to ensure that both Features are
activated.
Activation Dependency Rules:
Activation dependencies must applied by certain rules to avoid, Circular dependencies,
dependency chains that limit performance.
1. Same-Scope Rules:
If a Feature is dependent on another Feature at the same scope, and the second Feature
is not activated when the first one is activated, Microsoft SharePoint Foundation activates
the second Feature.
Chapter 3 of 82
If a Feature is deactivated, SharePoint Foundation deactivates a same-scope dependent
hidden Feature when the last visible Feature that dependet on that hidden Feature is
deactivated.
2. Cross-Scope Rules:
Cross-scope activation dependencies are not supported if the Feature depended upon:
i. is at a more restrictive scope. Ex: a site collection–scoped Feature, Web site–scoped
Feature.
ii. is not visible in the user interface.
iii. is not activated, activation of the depending Feature fails.
3. General Rules:
Dependencies can work only one level deep. In other words, dependency chains are not
supported. does support more than one level in activation dependencies.
You can target an activation dependency against hidden or visible Features, but hidden
Features cannot have activation dependencies.
When more than one Feature has a dependency on a given Feature, keep in mind the
danger of leaving one of the depending Features without the required Feature
dependencies. For example, B=>A A=>C .. deactiv B=> deactiv A but C is
still activated<ActivationDependencies>
<ActivationDependency
FeatureId="11111111-1111-1111-1111-111111111111" />
</ActivationDependencies>
Define solution dependencies.
When you deploy a solution with an activation dependency, SharePoint will check if this
parent solution is already deployed. If not, you will get an error message.
Solution dependencies must be defined in the solution manifest, i.e. the manifest.xml file in
your wsp package.
Organize SharePoint project items.
Packaging and Deploying SharePoint Solutions:
Creating Features and Packages:
I. Visual Studio
II. SharePoint solution package (.wsp) to bundle multiple features, site definitions and
assemblies.
Feature and Packaging Tool Support: A. Feature Designer and Package Designer.B. Packaging Explorer, a tool window.C. Solution Explorer.
Deploying SharePoint Solutions:
After you customize the Features and package in Visual Studio, you can create a .wsp file to
deploy to SharePoint servers. You can use Visual Studio to debug and test the .wsp only on
the SharePoint server on the development computer.
Deploying Files in SharePoint Solutions:
For example, to add an no compiled file (. xml file) to a SharePoint project:
1) Add a SharePoint "Layouts" Mapped Folder to your project. Add the .xml file to the new
subfolder. By default, the file is deployed to the SharePoint file system under ..\TEMPLATE\
LAYOUTS\Folder Name\.
Chapter 4 of 82
2) Add the .xml file to the folder of a SharePoint project item, and then change the
Deployment Type property of the .xml file from NoDeployment to another setting such as
RootFile or ElementFile.
3) If an added file does not apply to any specific project in the solution, you can add an
Empty SharePoint Project to your solution and then add the additional files to it. Another
alternative for deploying files to SharePoint, especially to the content database, is to add
a module to the project and then add the files to the module.
Create sandbox solutions
Scope features to constraint
Only Features scoped to the site collection or the website are possible in sandboxed
solutions.Farm and web application scope are not possible. Site collection features are
activatedautomatically when the solution activated
Restrictions on Sandboxed Solutions:
a) Triple Worker Processes.b) Low-Privileged Security Token for the Sandboxed Worker Process.c) Restrictive Code Access Security Policy for the Sandboxed Worker Process.d) Special Versions of the Microsoft.SharePoint.dll Assembly.e) Split Page Rendering System.f) Resource Usage Limitations.g) Farm-Relative Validation of Solutions.h) Farm-Relative Blocking of Solutions.i) Farm-Relative Blocking of Classes.
Identify SharePoint artifacts that can be used in sandbox:
What Can Be Implemented in Sandboxed Solutions:
I. Assembly
Refers to assemblies whose source code is part of the Microsoft Visual Studio sandboxed
solution project. Non-SharePoint assemblies cannot be deployed in a sandboxed solution.
II. Binding of content type to a list
III. Content type
IV. Custom action for a menu, the ribbon, or an administration page
V. Feature
VI. Only Features scoped to the site collection or the website are possible in sandboxed
solutions. Farm and web application scope are not possible.
VII. List/library instance
VIII. Site page, including both master page and content page
Application pages cannot be included in a sandboxed solution.
IX. Web Part
Only Web Parts derived from System.Web.UI.WebControls.WebParts.WebPart can be used in
a sandboxed solution. Web Part connections are not possible in sandboxed solutions.
X. Web template
A web template is deployed as a WebTemplate element along with an onet.xml file and
optionally a default.aspx file. A web template is functionally equivalent to a site definition
configuration. Site definition configurations cannot be deployed in a sandboxed solution.
Access data outside of sandbox scope:
Chapter 5 of 82
Sandboxed Solutions in Partnership with Full-Trust Proxies
Several ways that sandboxed solutions can escape the usual restrictions on what they can
access:
Full-trust proxy operations: Create a special kind of operation that runs in a full trust process,
but that can be called from a sandboxed solution. The operation is deployed as a farm
solution by a farm administrator who trusts it and is prepared to let sandboxed solutions call
it, this technique cannot be used when farm deployment is not an option, such as “SharePoint
Online”.
using client object model code to access resources that are not otherwise available to
sandboxed solutions.
Sandbox solution deployment, Upgrade sandbox solutions:
Installing a Sandboxed Solution:
Just as with a farm solution, there are two steps to installing a sandboxed solution, uploading
and activating.
a) Upload stage: The upload stage consists of uploading a sandboxed solution to the solution
gallery of a site collection. This parallels adding a farm solution.
b) Activation stage: The activation stage occurs after the solution is uploaded to a solution
gallery. Activating the solution makes it operate within the site by deploying files,
registering event receivers, and running solution validation. This parallels deploying a
farm solution.
1. A sandboxed solution is installed by a site collection administrator to the site collection's
solution gallery.
The following steps:
1) Click Site Actions, and then select Site Settings.
2) Click Solutions under the Galleries heading.
3) Click Upload Solution from ribbon.
Chapter 6 of 82
4) Browse to the sandboxed solution package (.wsp file). Click Open.
5) In the Activate Solution dialog box, click Activate to activate the solution.o If the sandboxed solution package contains a Feature it is activated automatically.
o When you add a sandboxed solution package through the object model, both site
collection–scoped and website-scoped Features must be activated on the Manage site
features page
2. SharePoint Management Shell (Windows PowerShell). The commands are Add-
SPUserSolution and Install-SPUserSolution.
3. Microsoft Visual Studio, you can perform all installation steps by selecting Deploy Solution on
the Build menu.
Uninstalling a Sandboxed Solution
1. There are also two steps to uninstalling a sandboxed solution.
A. Deactivation stage: from the site collection's solution gallery. Which reverses previous
actions
B. Deletion stage: from the solution gallery. A sandboxed solution cannot be deleted if it is still
activated. When a sandboxed solution is deleted, it is moved into the Recycle Bin and can be
restored or deleted permanently from the Recycle Bin.
2. using SharePoint Management Shell (Windows PowerShell). The commands are Uninstall-SPUserSolution and Remove-SPUserSolution.
3. On your development computer, in Visual Studio, you can perform all uninstallation steps by selecting Retract Solution on the Build menu.
Upgrading a Sandboxed Solution 1. Installing a new sandboxed solution package (.wsp file) that has the same solution ID as
the existing sandboxed solution but a different hash code.2. using SharePoint Management Shell (Windows PowerShell). The command is Update-
SPUserSolution (not Upgrade-SPUserSolution).
Implement custom solutions validators:
Validate Sandboxed Solutions using SPSolutionValidator:
What will happen?
If you have a custom Solution Validator hooked up with your farm, a custom error page will be
displayed, and the solution will not be activated.
Building a Solution Validator we need:
A Solution Validator
A feature to install/uninstall the validator in our Farm
Summary and reflections:
If you want to create some kind of check to automatically validate solution that are uploaded by
end-users in their Solution Galleries, this is the way to do it.
Solution validators are very easy to write, and they can be installed using a few different
approaches. My take is to create a farm feature, while you could still do it using powershell or in
any way you want through the object model.
Create a no-code solution
Configure no-code customizations for the SharePoint 2013 platformCreate XSLT for web parts
Create SharePoint 2013 no-code solutions
I. What is a SharePoint Composite? A SharePoint Composite is a no-code, do-it-yourself business solution that you can create quickly
by assembling, connecting, and configuring the basic building blocks of functionality available in
Chapter 7 of 82
SharePoint 2013 and Office 2013. A SharePoint Composite combines data, documents, and business processes in a useful, productive way.
Or a web application that you can use to incorporate data quickly into a simple, visual, and interactive solution. A SharePoint Composite can be: As simple as a custom webpage that uses a site list and several connected Web Parts. As sophisticated as a system that’s connected to a database by using Business Connectivity
Services (BCS).
II. How-tos for creating no-code solutions?
A. Using SharePoint 2013 Composites:
Provides links to many practical articles, walkthroughs, demos, virtual labs, and other formats
that show how to create no-code solutions.
B. Save, download, and upload a SharePoint 2013 site as a template:
Explains how to create site templates without using code so you can easily deploy no-code
solutions.
Design Manager in SharePoint 2013:
Get an overview of using Design Manager to brand your SharePoint 2013 site.
The designer will perform the following tasks: 1. Understand core SharePoint design concepts. 2. Create a mock-up of the design in HTML and CSS. 3. Implement the design by using Design Manager.
I. Use Design Manager to implement a design: "design" is simply a group of files that implement:
At least one HTML file that will be converted into a SharePoint master page.One or more CSS files.JavaScript files.Images.Other supporting files.
Create and upload JavaScript files
Uploading JavaScript (JS Files) as Javascript Display Template:
While working with SharePoint there is a common requirement to Upload JavaScript Files that
you want to use in one of your WebParts or with the new JS Link property of a List,Field,Form or
a WebPart in your SharePoint 2013 site.
You can either upload these .js files in:
I. The Styles, or
II. Site Asserts Library ,or
III. you can add it to the Master Page Gallery as a new JavaScript Display Template.
Chapter 8 of 82
1) Navigate to the Master Page Gallery (Site Settings -> under Web Designer Galleries -> Master
Pages).
2) Select Files tab and then Upload Document.
3) Browse to the new JavaScript file that you have created and select Ok.
4) Next select “JavaScript Display Template” in the Content Type drop-down.
5) Next specify the Name, Title, Description properties along with some other properties
Create Display Templates
Learn about display templates, including:
a. how they relate to Search Web Parts,
b. how the templates are structured,
c. how to map properties and use variables and jQuery, and
d. how to create a custom display template in SharePoint Server 2013.
In this article:
i. Introduction to display templates
Only Search Web Parts can use display templates. The Content Query Web Part is not
search-driven, and so does not use display templates.
You can view existing display templates in Design Manager, but you don't create them in
Design Manager the way that you create master pages and page layouts. Instead, you:
a) Open your mapped network drive to the Master Page Gallery.
b) Open one of the four folders in the Display Templates folder.
Note:
The folder you choose depends on the type of display template you want to use.
When you create a display template by copying the HTML file for an existing display template in
the Display Templates folder in the Master Page Gallery:
1) A .js file that has the same name is created in the location where you copied the
HTML file.
2) All markup required by SharePoint Server 2013 is added to the .js file so that the
display template displays correctly.
3) The HTML file and the .js file are associated, so that any later edits to the HTML file
are synched to the .js file when the HTML file is saved.
The syncing goes in one direction only. Changes to the HTML display template are
synched to the associated .js file. Unlike master pages and page layouts, when working
with display templates you can't choose to work only with the .js file by breaking the
association between the files. You must enter all the HTML and JavaScript in the HTML
file.
ii. Understanding the relationship between display templates and Search Web Parts There are two primary types of display templates:
a) Control templates determine the overall structure of how the results are presented. Includes lists, lists with paging, and slide shows.
b) Item templates determine how each result in the set is displayed. Includes images, text, video, and other items.
iii. Understanding the display template structure:
The HTML file that is used for a display template is a fully-formed HTML document, but it
does not represent a full HTML webpage. SharePoint converts the pieces of the display
template HTML file into JavaScript.
four major sections of a display template.
Chapter 9 of 82
1) Title tag: The text in the <title> tag in a display template file is used as the display name in
the Display Templates section of the Web Part edit pane
2) Header properties
3) Script block
Inside the <body> tag, you can see the following <script> tag:
4) DIV block
iv. Mapping input properties and getting their values
The header section of an item display template has a custom document property named
ManagedPropertyMapping. This property takes the managed properties that are used by
search and maps them to values that can be used by the display template.
property display name is the property name that shows in the Web Part editing pane
when the display template is selected.
property name is an identifier that uses localized string resources to look up the name of
the managed property.
managed property is a string of one or more managed properties, separated by
semicolons. This enables you to write a display template that can work with multiple item
types and that can use consistent rendering if compatible properties are present
v. Using jQuery with display templates
vi. Create a display template
Before you can create a display template by using the following procedure, you must have a
mapped network drive that points to the Master Page Gallery.To create a display template:
1. Using Windows Explorer, open the mapped network drive to the Master Page Gallery.2. Open the Display Templates folder, and then open the Content Web Parts folder.3. Copy the HTML file for a display template that is similar to what you want to create.4. Edit the HTML file that resides on the server , Each time that you save the HTML file, any
changes are synched to the associated .js file.5. Browse to your publishing site.6. Choose Settings, and then choose Design Manager.7. Choose Edit Display Templates. Your HTML file now appears.
Unlike master pages and page layouts, you can't use the preview page to see a live server-
side preview of your display template. To preview the display template, you must add a
Content Search Web Part to a page, and then apply the display template in the Content
Search Web Part edit pane.
Chapter 10 of 82
Chapter 5 Implement the user experience & information architecture (10‒15%)
Implement branding
Incorporate designer outputs
how to map a network drive to the Master Page Gallery so that you can use Design
Manager to upload design files in SharePoint Server 2013.
You can create a visual design for your website by using any web design tool or HTML editor,
and then use Design Manager to import the design into SharePoint. To do this, you have to
make sure that the design tool stores its files in your site's Master Page Gallery, which is where
SharePoint expects to find the files.
First, find the location of the Master Page Gallery.
1. Start Design Manager(Settings menu ....> Design Manager)
2. In the numbered list, select Upload Design Files.
3. Upload Design Files page contains the location of the Master Page Gallery. The location
probably ends in /_catalogs/masterpage/. This is the location to which you will map a
network drive.
4. Copy the location of the Master Page Gallery to the Clipboard.
On the computer that runs your design tool or HTML editor, map a network drive to the location
that you just copied. The procedure for mapping a network drive differs depending on the
computer's operating system:
1) In the Menu bar, tap or click Computer, and then tap or click Map network drive.
2) In the Drive list, tap or click a drive letter.
3) In the Folder box, enter the path of the folder(location of the Master Page Gallery ).
Use Design Manager functionality
I. Introduction to Design Manager
Design Manager is a feature in SharePoint 2013 that makes it easier to create a fully
customized design to represent your organization's brand and not "look like SharePoint,"
while using the web-design tools that you're already familiar with.
Design Manager is a publishing feature.
The designer will perform the following tasks: a) Understand core SharePoint design concepts. b) Create a mock-up of the design in HTML and CSS. c) Implement the design by using Design Manager.
II. Use Design Manager to implement a design "design" is simply a group of files that implement:
At least one HTML file that will be converted into a SharePoint master page. One or more CSS files. JavaScript files. Images. Other supporting files
Manage device channels: you want to consider what devices your site should target and what will be the user
experience on each device. certain class of [ smart phones or tablets ]. Depending on what channels you define, you may want several designs, so several files
[HTML,CSS,Masters,..].
Chapter 1 of 82
You can render a single publishing site in multiple ways by mapping different designs to different devices.
Device channels are created and stored in a SharePoint list in which order matters.Upload design files:
When you create a design, you can use whatever HTML editor you prefer and work with files locally on your computer. But, eventually, you will have to upload those files to the Master Page Gallery of your SharePoint site, so that you can use Design Manager to convert, preview, and publish your design.
The easiest way to upload and continue to work on design files is to map a drive on your computer to the Master Page Gallery of your SharePoint site.
Edit master pages: Creating a fully branded master page that contains [ navigation and search,..] is basically a
three-step process:A. Convert an HTML file into a SharePoint master page.B. Preview the master page and fix any issues.C. Add SharePoint snippets to the master page.
Edit display templates: Search-driven Web Parts use display templates for two main purposes:1) To map the managed properties that are returned in search-result items to properties that
will be available for JavaScript, including whatever custom JavaScript you choose to implement.
2) To use HTML and CSS to present and style how those properties are displayed. Edit page layouts:
The process for creating a page layout is a bit different from creating a master page. For a master page, you start with an HTML design, convert that into a SharePoint master page,
and then continue to edit the associated HTML file. But for a page layout, you first create the page layout in Design Manager, which creates an .aspx
file and an HTML file, and then you edit the associated HTML file from the mapped drive in your HTML editor.
Publish and apply design: i. Most assets used by your design, such as images, HTML, CSS, and JavaScript files, will reside
in the Master Page Gallery. ii. The Master Page Gallery is a SharePoint document library that by default has versioning
turned on, which creates major and minor (draft) versions each time you edit a file.iii. Before you can apply your design to a site, you first have to publish a major version of each
file or asset used by your design.
iv. If you are designing your site in a test environment, you should turn off versioning for the
Master Page Gallery, so that you don't have to remember to publish every file before you
preview the site. But this is not a best practice if you are designing on a live site.
v. After you publish all the design files, you are ready to apply the design by assigning your
finished master pages to your site.
vi. Each site can have a different master page assigned to each device channel, and this page
of Design Manager is where you apply a master page to a channel
Apply custom themes
how themes can be used to customize the look and feel of sites.
I. Themes overview
The Change the look wizard is the entry point to the theming experience.
The theming experience in SharePoint 2013 was redesigned to simplify the process of customizing
sites, by changing the site layout, color palette, font scheme, and background image.
II. Theming experience components i. Color palette A color palette, or color scheme, defines the combination of colors that are used
in a site, Color palettes are XML files (.spcolor files). They are stored in the Theme Gallery of the root site /_catalogs/theme/15/
Chapter 2 of 82
ii. Font scheme A font scheme defines the fonts that are used in a site. Seven font schemes are available,Font schemes are XML files (.spfont files). They are stored in the Theme Gallery of the root site /_catalogs/theme/15/
iii. Background image The background image that is used in the site.iv. Master page A master page defines the chrome (the shared framing elements) of a site. The
theming experience lets users select the master page to apply to a site.v. Master page preview A master page preview is used to render a preview image of the
selected theme components. Each master page must have a corresponding master page preview file for the master page to be available in the theming experience.
vi. Composed look Is the color palette, font scheme, background image, and master page that determine the look and feel of a site. To access the composed looks list, on the Site Settings page, under Web Designer Galleries, choose Composed looks.
vii. Change the look The Change the look wizard is the entry point to the theming experience that lets users change the look and feel of their site. To access the Change the look wizard, choose the Settings icon, and then choose Change the look.
viii. Design gallery The design gallery is the first page in the Change the look wizard. The design gallery shows a thumbnail view of available designs.
III. Using themes
A. Preinstalled themes
The theming experience lets users customize the preinstalled themes when you want additional
font schemes or color palettes.
When a preinstalled theme is modified, a new theme named Current is created automatically
after the theme changes are applied.
B. Custom themes
Is a saved modified theme, you can create a list item in the Composed Looks list that contains
the same master page, color palette, font scheme, and background image URLs of the modified
theme (the modified theme is listed as Current in the Composed Looks list)
Export the design
Learn how to build and export the visual design of a SharePoint site collection as a package.
Overview of Design Packages
Design Manager can help build and export the visual design of a SharePoint site collection as a
package.
This package can easily be distributed to customers, or other designated groups, for installation on
their site collections.
This new feature reduces the complexity of transporting designs, and makes it easier for
customers to outsource the visual design of their sites. For example, some usage scenarios can
include the following:
New Design—The agency can create the site and easily package the contents for importing
back into the company SharePoint farm.
Cross-Site Publishing—might have to share a visual design across multiple site collections.
reduced administrative support and complexity.
Creating a design package: A user creates a design package, called a SharePoint solution package (.wsp file) on their
SharePoint site, through Design Manager in Site Settings. The step for creating the package follows other Design Manager steps for branding and
publishing a SharePoint site, including 1. Uploading design files, 2. Creating a master page, 3. Editing page layouts.
After the site is published, it is a relatively simple process to create the .wsp file for export.
Chapter 3 of 82
Figure 1 shows the option in Design Manager for naming and creating the design package.
Alternatively, you can import a design package from another SharePoint 2013 site collection through Design Manager two ways: A. on the Welcome page, or B. by choosing Import design package in Site Settings.
If you want your design to be published on the target of import, you should publish all design assets or disable major versioning in design-related libraries on the source of export. Design Manager exports only the most recent version of each asset from the source. For example, if you have version 1.1 of a master page on the source it will be copied to the target as a draft. But, version 1.0 is not copied. Also, files that are checked out are not exported.
Exporting and importing a design package:
You can approach an end-to-end packaging workflow several ways, with much of the approach
depending on your objectives and available design resources. You may decide to outsource to a
vendor agency, or do the work in-house if you have internal resourcing.
Understanding design package contents:
Only customized files are included in design packages.
Several files are included in the design package .wsp file when it is created through Design
Manager. The process exports files from various lists and libraries to form the overall package.
While importing to a site collection, these files are distributed to different locations based on file
type Any created device channels, and their configurations, are also imported when the design
package is unloaded. But, you have to re-associate master pages to specified device channels because these mappings will not be configured.
When importing a design package, an alternate CSS URL is not set, even if one was configured on the source of export. CSS classes should be stored in an external file in the Master Page Gallery and not in the master page file itself. Table 2. Summary of design package contents and file exportation locationsExport Location Exported AssetsDocument libraries Master Pages Gallery
Themes Gallery
Style Library
Site Assets Library
Content types, fields Content types that inherit from the Page content type
Chapter 4 of 82
Lists Design Gallery
Composed looks
Device channels
Create Master Page
With Design Manager, you can convert an.html file into a SharePoint 2013 master page,
a .master file. After the conversion, the HTML file and master page are associated, so that when
you edit and save the HTML file, the changes are synced to the associated master page.
I. Introduction to converting a master page
With Design Manager, you can convert an.html file into a SharePoint 2013 master
page,when you edit and save the HTML file, the changes are synced to the associated
master page.
Why do you want to convert an HTML file, instead of creating a .master file from scratch?
Unlike creating a .master file you don't have to know about ASP.NET or the SharePoint-
specific markup; instead, you can focus on designing your site in HTML, CSS, and JavaScript.
When you convert an HTML file into a master page:
A .master file with the same name as your HTML file is created in the Master Page
Gallery.
All markup required by SharePoint 2013 is added to the .master file so that the master
page renders correctly.
Markup such as comments, <div> tags, snippets, and content placeholders are added to
your original HTML file.
The HTML file and master page are associated, so that any later edits to the HTML file are
synced to the .master file when the HTML file is saved.
The syncing goes in one direction only. Changes to the HTML master page are synced to the
associated .master file, but if you choose to edit the .master file directly the changes are
not synced to the HTML file. Every HTML master page (and every HTML page layout) has a
property named Associated File that is set to True by default, which creates the association
and syncing between files.
If you have a pair of associated files (HTML and .master) and you edit the .master file
without breaking the association, the changes to the .master file will be saved, but you
can't check in or publish the .master file, so those changes are not saved in a meaningful
way.
If you're a developer comfortable working with ASP.NET, you can choose to work only with
the .master file by breaking the association between the files.
II. Prepare the HTML file for conversion
Consider the SharePoint page model. only one HTML file will be converted into the master
page. An HTML file can be converted into a master page, but an HTML file can't be
converted directly into a page layout because a page layout requires page fields.
Make sure your HTML file is XML-compliant. this requirement overrides some HTML 5
standards—for example, remove any <form> tags from your HTML file.
Consider these important guidelines for your CSS references:
i. Don't put <style> blocks in the <head> tag. These styles are removed during
conversion. Instead, link from your HTML file to an external CSS file.
ii. Add ms-design-css-conversion="no" to the <CSS link> tag if you're using a web font.
Chapter 5 of 82
iii. Be cautious about applying styles to general HTML tags like <body>, <div>, and <
img>. Everything within your SharePoint design, including the ribbon, is within the
<body> tag
iv. Many designers style the navigation by applying classes to <ul> and <li> elements.
But, SharePoint 2013 uses a dynamic navigation control, which you can add to your
master page from the Snippet Gallery. SharePoint 2013 navigation controls have styles
applied by default that you have to override.
Consider these potential issues about file naming:
I. If you have Index.html and Index.htm, those files will have the same .master file.
II. If you have Design/Index.html is available for conversion into their own, separate .master
files, but they'll both show up as Index.html in the master page list in Design Manager.
III. If you're adding a JavaScript widget, make sure the <script> start tag is on its own line.
III. Convert the HTML file into a master page:
1) Browse to your publishing site.
2) Choose Settings, and then choose Design Manager.
3) Choose Edit Master Pages.
4) Choose Convert an HTML file to a SharePoint master page.
5) In the Select an Asset dialog box, browse to and select the HTML file that you want to
convert.
6) Choose Insert.
At this point, SharePoint 2013 converts your HTML file into a .master file with the same
name.
In Design Manager, your HTML file now appears with a Status column that shows one of two
possible statuses:
1. Warnings and Errors
2. Conversion successful
7) Follow the link in the Status column to preview the file and to view any errors or warnings
about the master page.
The preview page is a live server-side preview of your master page. The top of the preview
displays any warnings or errors that you may have to resolve by editing the HTML file in an
HTML editor.
The preview page also contains a Snippets link in the upper-right corner. This link opens the
Snippet Gallery, where you can begin replacing static or mockup controls in your design
with dynamic SharePoint controls.
8) To fix any errors, edit the HTML file that resides directly on the server by using an HTML
editor to open and edit the HTML file in the mapped drive. Each time you save the HTML
file, any changes are synced to the associated .master file.
9) After your master page previews successfully, you will see a <div> tag that gets added to
your HTML file. You may have to scroll to the bottom of the page to see the<div> tag.
This <div> is the main content block. It resides inside a content placeholder named
ContentPlaceHolderMain. At run time, when a visitor browses your site and requests a page,
this content placeholder gets filled with content from a page layout that contains content in
a matching content region. You should position this <div>where you want your page
layouts to appear on the master page.
If your HTML file contains static or mockup content in the body of the page, now you begin
the process of removing that static content from the HTML master page and applying those
styles to other elements of the SharePoint page model, such as page layouts, page field
controls, snippets, and display templates.
IV. Understanding the HTML file after conversion
Chapter 6 of 82
When you convert an HTML file into a master page, many lines of markup get added to your
HTML file. this markup is critical for converting your HTML file into the .master file that
SharePoint actually uses.
The markup that gets added includes tags before and in the <head> tag, snippets, and
content placeholders.
Types of markup that are added to the HTML file:
Document properties The <mso> tag contains SharePoint metadata, information about
the file itself.
SharePoint namespace registration The <SPM> tag ("SharePoint markup") provides a
line registering a SharePoint namespace.
Comments The <CS> and <CE> ("Comment start" and "comment end") tags are ignored .
Snippets The <MS> and <ME> ("markup start" and "markup end") tags denote the
beginning and end of a SharePoint control or a snippet. A snippet is a SharePoint control
that adds SharePoint functionality to your page. You can add snippets yourself by using the
Snippet Gallery.
Preview blocks The <PS> and <PE> ("Preview start" and "preview end") tags surround a
section of HTML code that you shouldn't edit because this section affects only the design-
time preview.
SharePoint IDs Two of the snippets added to your HTML file during the conversion (the
Page Head Contents snippet and the SharePoint Ribbon) have an associated SharePoint ID,
or SID (00 and 02, respectively). These IDs make it possible to shorten the snippets and
make the HTML in the page easier to read.
Added snippets two of the snippets that are added to your HTML file, Added automatically
during the conversion, but they're not available for you to add from the Snippet Gallery.
The Ribbon For content authors to be able to create pages and author content on your
SharePoint site, The ribbon is contained in a security-trimming snippet, so that when a
visitor browses your site, the ribbon is displayed only to authenticated users, not
anonymous users.
ContentPlaceHolderMain At the bottom of the <div id="s4-bodyContainer"> tag, before the
closing </body> tag, the conversion process inserts a content placeholder named
PlaceHolderMain. Inside this snippet is the black-bordered, yellow <div> that appears in the
design view of your HTML editor, or in the server-side preview in Design Manager.
This <div> represents the area where the content specified by your page layouts and
pages will go.
Create a channel
Chapter 7 of 82
Device channels are available only for SharePoint 2013 publishing sites.
Create, Change, Delete, Change Order of Device Channels :
1. Start Design Manager. (For example, on the Settings menu, choose Design Manager.)
2. In the numbered list, select Manage Device Channels.
To create a device channel:
1. Start Design Manager. (For example, on the Settings menu, choose Design Manager.)
2. In the numbered list, select Manage Device Channels.
3. Choose Create a channel.
4. New Item page, in the Name text box, enter a name for the device channel.
5. Enter an alias for the device channel. The alias must be alphanumeric characters and may not
contain spaces. You will use the alias to refer to the device channel in code and in other
contexts.
6. Enter a brief description of the devices or browsers that the channel will capture.
7. In the Device Inclusion Rules text box, enter the user agent substrings for the channel. A
request for a webpage will use this channel if any of the strings that you provide match the user
agent string of the request.
8. If you are ready to make the channel available to render pages, select the Active check box.
Chapter 8 of 82
9. Choose Save.
Implement navigation
Create a custom navigation provider,
How to: Extend the Navigation Provider in SharePoint Server
by deriving a custom provider class from any of the default site map providers, which supplies
several benefits, such as navigation node caching and security trimming.
1. Create a Microsoft Visual C# class library project, add the required references, and then
build the project.
2. Copy the .dll file that you created in step 1 into the SharePoint Server virtual directory’s bin
folder.
3. Create the following entry in the web.config file for the Web application, <add name="MyCustomNavigationProvider" type="MyCustomNav.Navigation, MyCustomNav" NavigationType="Current" />
and then set the trust level to Full.
4. Create a custom master page, and code under the top navigation’s ContentPlaceHolder
element.
5. Reset Microsoft Internet Information Server (IIS). Your SharePoint Server site should now
show the updated navigation from the extended navigation provider.
Creating Custom Navigation That Crosses Site Collection Boundaries
You can implement global navigation by creating a custom navigation solution that can cross
site collections.
Implementing a Custom Site Map Provider
If you want a custom solution, you must implement a custom site map provider, This
allows you to make your site map useable by any navigational control you choose, such
as a menu, a breadcrumb or a tree.
StaticSiteMapProvider class. This class translates a site map that is in persistent
storage to one that is stored in memory.
The contents of the site map are read once, This is when the application pool for a Web
site starts.
The StaticSiteMapProvider class is a good choice when the site map changes infrequently.
When the site map changes Frequently, the site map provider will not reflect those
changes until the application pool recycles.
Using the Hierarchical Configuration
When you implement a custom site map provider, you must decide on a persistent storage
mechanism for the site map. There are number of options, including
A. Custom database table,
B. SharePoint_Config database, or
C. SharePoint list.
Other Considerations
It is important to thoroughly test the code that implements the custom site map provider. An
exception that occurs while
A. Site map provider is initializing can prevent your application from loading, even if the
site map provider is not used on a page that a user requests.
B. Faulty site map provider can be difficult to troubleshoot.
One of the drawbacks of a custom site map provider is that SharePoint does not provide a
user interface (UI) that allows you to modify the site map at run time. This can make an
Chapter 9 of 82
application's navigation static because it is difficult to add new nodes. On the other hand,
SharePoint's site map providers are dynamic. It is simple to update and modify the site
structure if you use them.
Create taxonomy-based navigation,
Learn about the taxonomy-driven managed navigation feature in SharePoint 2013.
I. Introducing managed navigation feature:
A well-designed navigation tells your site's users a lot about the business, products, and services that
the website offers. By updating the taxonomy behind the navigation, businesses can drive and keep
up with change without having to recreate their site navigation in the process.
Enables you to design site navigation that is driven by managed metadata and create friendly URLs .
Provides an alternative to the traditional SharePoint “structured navigation” that is based on the
structure of SharePoint.
Because managed navigation is driven by taxonomy, you can use it to design site navigation around
important business concepts without changing the structure of your sites or site components.
II. How managed navigation works
Managed navigation provides a framework for dynamically generated pages and provides an
associated friendly URL.
Instead of requiring separate pages to be authored for each category in the taxonomy, the framework
provides a templating and inheritance mechanism that creates the landing pages for each navigation
link.
Managed navigation APIs are built into the taxonomy and publishing libraries in SharePoint 2013.
Taxonomy navigation namespace, providing methods to associate metadata items with navigation
elements.
Other classes, like TaxonomySiteMapNode, enable you to provide metadata with various site
navigation elements, such as site map nodes
Other classes enable caching and context for managed navigation.
You can display taxonomy-driven navigation links in the Global Navigation. which often appears at the
top of a site and displays the top-level content categories.
III. Friendly URLs and the managed navigation provider
When you navigate to the root of any site that uses the managed navigation provider, the Site
Welcome Page the URL you see is rewritten to friendly format.
Any page, including your site's Welcome Page, can have a friendly URL. Depending on how you
configure your site, most pages automatically get a friendly URL.
IV. Managed Navigation APIs
The taxonomy API provides several new methods and properties in SharePoint 2013 that you can
use to customize terms, term sets, and other metadata elements in the term store for use in site
navigation scenarios. These APIs are available in the .NET client, .NET server, Silverlight, and
JavaScript programming models.
V. Code Example: Customizing managed navigation with the .NET client object model (CSOM) API
When you use the .NET client object model for taxonomy, you can create a new navigation term
set if a term store exists for the current site collection, or
Convert an existing term set into one that supports managed navigation.
VI. Code Example: Customizing managed navigation with the .NET server object model API
You can use the .NET server taxonomy classes and methods in the
Microsoft.SharePoint.Taxonomy and Microsoft.SharePoint.Publishing.Navigation namespaces to
create a new navigation term set.
VII. Global navigation in SharePoint 2013
Summary:
Chapter 10 of 82
One of the new capabilities of SharePoint 2013 is Managed Navigation that allows you to define
site’s navigation using Managed Metadata.
Unfortunately Managed Navigation is bound to a specific Site Collection and cannot be reused
across different Site Collections.
Using the standard capabilities of SharePoint 2013 you can leverage Managed Metadata and
build global navigation within your organization.
Create search-driven navigation
Configure refiners and faceted navigation
You can apply faceted navigation only to publishing sites that use managed navigation. how to map a crawled property to a refinable managed property, how to enable a managed property as a refiner, and how to configure refiners for faceted navigation.
You can add refiners to a page to help users quickly browse to specific content. Refiners are based on managed properties from the search index. To use managed properties as refiners, the managed properties must be enabled as refiners, or crawled properties must be mapped to managed properties that are enabled as refiners.
Faceted navigation is the process of browsing for content by filtering on refiners that are tied to category pages. Faceted navigation lets you specify different refiners for category pages, even when the underlying page displaying the categories is the same.
Before you begin Because SharePoint 2013 runs as websites in Internet Information Services (IIS), administrators
and users depend on the accessibility features that browsers provide. When a catalog is crawled, SharePoint Server 2013 automatically creates managed properties for
all site columns that contain values. Map a crawled property to a refinable managed property in SharePoint site collection
administration Site collection administrators can configure refiners because the search schema has many
managed properties that are enabled as refiners by default. To configure refiners in Web Parts or in Term Store Management, you must start a full crawl of the
content source that contains the refinable managed properties. Enable automatically created managed properties as refiners in SharePoint Central
Administration All automatically created managed properties use the Text data type. you should only enable an automatically created managed property as a refiner if it is based on a
site column that uses the data type Text. For other data types, you must create a managed property, add the type code to the property
name, and enable the managed property as a refiner. Enable a term set for faceted navigation Add refiners to a term set Set intervals for refiner values Add JavaScript to a page to display refiners in the correct format Configure Faceted Navigation for a Product Catalog in SharePoint 2013
Refining makes you able to narrow down the result set, making it easier to find what you are looking for. Faceted Navigation is the ability to define different refiners for different terms in the taxonomy in a product catalog.
Enabling Faceted navigation
Chapter 11 of 82
In order to see refiners, let’s add the refiner web part to the category page in the product catalog. Configure refiners
Configure Faceted Navigation
Chapter 12 of 82
Configure global/current navigation:
Navigation controls overviewNavigation controls can be displayed on master pages, page layouts, and web parts
you can link to the following: Sites (below , peer, higher ) in the site structure. Web pages in a site. You can create links to arbitrary locations, such as to an external Web site.
Navigation links in SharePoint Server are security-sensitive.you can customize the following:
The site map provider. The data source, which anchors and filters the structure that is provided by the site map
provider. The menus, which control the visual appearance of the navigation elements and how deep a
hierarchy to display.
Navigation controls on master pages A master page defines the outer frame of the Web pages in a site. Master pages contain the
elements that you want all pages in your site to share, such as branding information; common commands, such as Search; and navigation elements that you want to be available throughout the site. This includes top link bar navigation, and Quick Launch navigation.
Top link bar navigation links to the sites that are one level below the current site in a site hierarchy. Administrators can customize it. It make it possible for users to easily switch from one site to another without having to return to
the site home page.Other top link bar configuration features include the following:
Linking to the Web pages of all the top-level sites. Linking to specified external sites. Linking to specified sites or pages that are anywhere in the site. Organizing links under headings. Manually sorting the items on the top link bar. Restricting the maximum number of items to show at the global navigation level. Customize the appearance and functionality of Quick Launch navigation by using SharePoint
Designer or Visual Studio .
Chapter 13 of 82
o Quick Launch navigation highlights the important content in the current site, such as lists and libraries. It is common for
Quick Launch navigation to appear on the left of each page in a site.Quick Launch navigation configuration features include the following:
Linking to sites that are on the same level of the site hierarchy as the current site. Linking to specific external sites or to pages in the current site. Organizing links under headings. Manually sorting the items in the Quick Launch navigation. Restricting the maximum number of items to show at the Quick Launch navigation level. Customize the appearance and functionality of Quick Launch navigation by using SharePoint
Designer or Visual Studio .Breadcrumb navigation
Displays a dynamically generated set of links at the top of Web pages, to show users their current position in the site hierarchy.
Customized by using SharePoint Designer or Visual Studio .Tree view navigation
Tree view navigation displays site content, such as lists, libraries, and sites that are below the current site, in a hierarchical structure. It is common for tree view navigation to appear on the left of each page in a site.
By default, tree view navigation is turned off. Site administrators can add tree view navigation to a site by using the Tree View page. To enable tree view, in Site Actionsclick Site Settings, in the Look and Feel area, click Tree view, and then select the Enable Tree View check box.
Metadata navigation Metadata navigation displays metadata about library and list content in tree view navigation,
and makes it possible for users to filter library or list content based on specified fields. Site administrators can configure metadata navigation by using the Metadata Navigation Settings page for a list or library to configure the navigation hierarchies and key filters that are available to users. Metadata navigation is displayed only when a user views the list or library for which metadata navigation has been configured.
Navigation controls on page layouts A page layout defines a layout for a Web page by providing Microsoft ASP.NET controls in which
the contents of pages are displayed. You can add navigation controls to a page layout to support navigation links in Web pages by
using SharePoint Designer or Visual Studio . When a navigation control is inserted on a page layout, Web pages that use that page layout
display the control together with the content of the page. SharePoint Server includes the following navigation controls that can be added to page layouts:
Summary Links Table of Contents Content Query
Summary Links You can use the Summary Links control to add a set of links to a page. You can control the
appearance, organization, and presentation of the links that you add to a Summary Link control.You can add a Summary Link control to a page layout in three ways:
1) You can add the control directly to the page layout and configure the links. When you do this, any page that uses the page layout displays the links.
2) You can add the control as a field control on the page layout. When you do this, you can choose to configure the links, and you can also choose to allow authors to modify the links and add new ones.
3) You can add the control as a Web Part to a Web Part zone. When you do this, authors can modify the links, add new ones, and delete the Summary Link control.
Table of Contents You can use the Table of Contents control to add a table of contents of all or part of your site to
a page layout so that top link bar and Quick Launch navigation is included in the master pages of the site.
When you add a Table of Contents control to a page layout, you specify which part of your site collection the control should display, how the links are presented, and how they are organized.
Chapter 14 of 82
You can add a Table of Contents control to a page layout in two ways:1) You can add the control directly to the page layout and configure it. When you do this, any page
that uses the page layout displays the table of contents.2) You can add the control as a Web Part to a Web Part zone. When you do this, authors can
modify the scope of the Table of Contents control.Content Query
You can use a Content Query control to link to pages or other items that are displayed based on a query that you design. You can build complex queries by using the Content Query control. You can also filter queries that are based on items in a library or list.
You can add a Content Query control to a page layout in two ways:1) Directly to the page layout and configure it. When you do this, any page that uses the page
layout displays the results of the query.2) Indirectly as a Web Part to a Web Part zone. When you do this, authors can modify the query or
delete the Content Query control.Navigation Web Parts
A Web Part is a control that authors can insert into a Web Part zone on a page and configure. The Summary Links, Table of Contents, and Content Query controls each have Web Part
counterparts that page authors can insert into Web Part zones on pages. You can include a Rich Text Editor control on a page, which will allow users to add Web Parts
directly to the Rich Text Editor Web part.The following navigation Web parts are available only on Publishing sites:
Summary Links Allows authors to create links that can be grouped and styled. Table of Contents Displays the navigation hierarchy of your site.
Customize UI elements
Customize the ribbon
Can be customized by using Server ribbon XML and ECMAScript (JavaScript, JScript). The XML
defines the controls on the ribbon; the JavaScript performs actions on the page or an object on
the page.
When customizing the Server ribbon, you can add, replace, and remove controls, groups, and
tabs. Customizations to the ribbon are defined by using Server ribbon XML in a Feature and can
be deployed in a solution package (.wsp file).
Learn about the components that make up the SharePoint Server ribbon and how to customize
the ribbon by walking through two ribbon customization scenarios.
Introduction to the SharePoint Server Ribbon
Chapter 15 of 82
SharePoint Server Ribbon Architecture
Customizing the SharePoint Server Ribbon1) Declarative approach, as described previously in this article, is done by using Features;
specifically the <CustomAction /> element with the<CommandUIExtensions /> child element.
2) The programmatic approach involves adding the declarative constructs, as strings, to the Server ribbon objects.
Customizing the Built-in SharePoint Server Ribbon ComponentsDevelopers can customize the ribbon in three ways:
A. Add components to the ribbon (tabs, contextual tab groups, groups, and controls).B. Modify existing components in the ribbon.
Chapter 16 of 82
C. Remove existing components from the ribbon.
Customize the edit control block (ECB)
Hide a Menu Item in the ECB from SharePoint List Items
You can add new custom actions to the Edit Control Block (ECB) menu by using the Features
framework.
hide ECB menu items, you must create a customcore.js file, modify this file to hide menu
items, and then render it through a custom master page.
How to: Modify the User Interface Using Custom Actions
Using Features makes it easy to add actions to menus and the Server ribbon in Microsoft
SharePoint Foundation.
Create the SharePoint Project Empty SharePoint Project. Deploy as a sandboxed solution. Click Finish. Add New Item Empty Element
Add Buttons to the Server Ribbon
Add an Item to the Site Actions Menu
Add an Edit Control Block Menu Item
Customize the status bar and notifications
These two areas give information in context without distracting users. Both status messages
and notifications are controlled by using the ECMAScript (JavaScript, JScript) object model. It appears as a bar below the Server ribbon and has four predefined background colors that are
assigned a level of importance. The status bar can contain multiple messages but will only reflect the color that equates to the
highest level of importance, or priority. The message in the status bar is HTML and can contain links or visual elements. The table below
describes the color values and their level of importance.Value PriorityRed Very ImportantYellow ImportantGreen SuccessBlue Information
The status bar is accessed by using the JavaScript and server object models.
Notifications are used to show transitory messages such as the status of an operation on the
page. Notifications appear on the right side of the page underneath the ribbon.
Introduction to System Status Notifications in SharePoint 2013:
System Status Notifications present important information about a SharePoint deployment and
its availability, whether during upgrades, routine maintenance, or conversion to read-only.
SPWebApplication Properties:
UpgradeReminderDelay
is used to enable users to suppress the upgrade availability System Status
Notification for a specified period of time.
UpgradeMaintenanceLink
property is used to provide users additional information during the site collection
upgrade process.
ReadOnlyMaintenanceLink
property is used to provide users additional information when a site collection is set
to read-only or a content database is configured to read-only in Microsoft SQL Server.
UpgradeEvalSitesRetentionDays
Chapter 17 of 82
property is used to specify the default number days after which upgrade evaluation
sites will be deleted.
SPSite Properties:
UpgradeReminderDate
property is used to specify a date after which site collection administrators will be
reminded to upgrade the site collection.
ExtendUpgradeReminderDate
The ExtendUpgradeReminderDate SPSite property is used to extend the upgrade
reminder date for a site collection by the days specified at UpgradeReminderDate.
AllowSelfServiceUpgrade
The AllowSelfServiceUpgrade SPSite property is used to specify whether version to
version upgrade is allowed on a site collection.
Customize the modal dialog window
Opening a SharePoint Modal Dialog Box from an InfoPath Form:
Many page activities in Microsoft SharePoint open a modal dialog box that lets you complete a task
without navigating away from the current page. When the dialog box opens, the background darkens
(the so-called lightbox effect), which indicates that the page is inactive. You must deal with the dialog
box before you can return to the page.
Sample Application: InfoPath Form Hosted on a SharePoint Site
Rgr
Chapter 18 of 82
dfd
Building the InfoPath Form Hosted on a SharePoint Site Sample Application
Publish to SharePoint
Chapter 19 of 82
The new Hover Over\Preview\Callout Popups in SharePoint 2013
Create Callouts in SharePoint
Microsoft has added new a Framework for Creating Callouts (Notification or Hover Over Popups) in
SharePoint 2013. These CallOuts gets displayed in few of the Lists and Libraries and in Search results
as Preview Panes.
Fgg
The good news is that these CallOuts or Hover Over Popups Can be fully Customized.
Callout.Js - This new JavaScript file added in the layouts folder and contains methods
for CalloutManager class.
CalloutManager - This is a new class to help Create an instance of CallOuts\Hover Popups
in SharePoint 2013.
Select areas for focus on content
Chapter 20 of 82
Hide Quick Launch\Left Nav using “Focus on Content” in SharePoint 2013
there is a new button in the top Sharing bar called “Focus on Content” which lets you
highlight the Content area by hiding the quick Launch or Left Nav on the page.
before
after
Customize the upgrade notification
Summary:
A completely revised, backward-compatible upgrade experience is designed to balance
the needs of users with those of IT. Because changing software is often difficult,
SharePoint Server 2013 enables IT to upgrade SharePoint Server 2010 without having to
upgrade users’ sites and content. These upgrades are deferred to the users, allowing
them to choose when the time is right.
New evaluation site collections allow users to request an evaluation of the upgrade prior
to upgrading production content; if satisfied with the experience, site collection
administrators then can upgrade their content. It’s important to note that whether you
have deployed SharePoint Server 2010 on-premises or subscribe to SharePoint Online in
Office 365, the full upgrade capability is available.
Chapter 21 of 82
Chapter 6 Create business processes (10‒15%)
Create event receivers and timer jobs
Plan the use of event receivers
1.1.1. Introduction to Events in SharePoint Foundation events model relies on managed components called event receivers that respond to
SharePoint Foundation objects when specific triggering events (adding, moving )take place.
You create an event receiver by inheriting from one of the SharePoint event receiver base classes. After you have created the event receiver, you implement event handlers by overriding methods on the event receiver class.
The class is then compiled into an assembly and placed in the global assembly cache (GAC); then, you bind your event handlers to an event host( SP Object ).
SharePoint Foundation Event Model is built upon:i. Before and After Events: Before:
synchronous events. This provides an opportunity for SharePoint Foundation to perform tasks after a specified action has occurred, but before data is committed to a database.
Used in data validation You can also use Before (or synchronous) events to cancel user actions – ex: data validation
fails. their member names end with the "-ing" suffix – for example, ItemAdding, ListAdding, and
so forth.After:
Execute after user actions are committed to the content database . This provides an opportunity to develop code that executes logic that occurs after a user has
completed a specific action. Because After events execute in a different process from the triggering action, they can
execute either synchronously or asynchronously. Their member names end with the "-ed" suffix – for
example, ItemDeleted, WebProvisioned, and so forth.ii. Event Hosts:
Event hosts are objects, such as site collections, Webs, lists and list items, that expect to receive events – or, in other words, objects whose event receivers “listen” for SharePoint Foundation events.
Each of the event host (Objects)types has specific event receiver base types from which you can inherit, to Create an event receiver collection.
iii. Event Receivers and Handling Events: SharePoint Foundation event handlers are a compiled module of custom managed code whose
invocation is triggered by a specified event that you have specified. Event handler code is compiled into a .dll file and deployed to the GAC.
iv. Binding Event Handlers ”Register”: After your event handler code is compiled and deployed to the GAC, you need to bind it to a
receiver object. Also known by the term “register,” binding is the process by which event handler code is associated with an object type.
Two ways binding:A. uses declarative XML within a SharePoint Feature, either by list type or by content type.B. implement your event handler binding by writing code that implements classes in the SharePoint
object model
Timer jobs,Creating Timer Jobs in SharePoint that Target Specific Services
1.1.2. Overview of Timer Jobs in SharePoint Timer jobs are executable tasks that run on one or more servers at a scheduled time.
They can run periodically and independently of users
Chapter 1 of 82
they can offload long-running processes from your web front-end servers so increases
the performance
they can run code under higher privileges than the code in your SharePoint site and
application pages.
Because SharePoint timer jobs run in the background, they perform their tasks behind
the scenes
1.1.3. Preparing to Create a SharePoint Timer Jobnew empty project
1.1.4. Creating a SharePoint Timer Job add new item >> class >> SPJobDefinition class.
1.1.5. Enabling Configuration for Your SharePoint Timer Job To store configuration data for the job, create classes to contain that configuration and
store it in SharePoint. First, the class must inherit from the SPPersistedObject class.
1.1.6. Deploying Your Timer Job you must add a SharePoint Feature to enable your SharePoint administrators to use the
functionality in SharePoint. A SharePoint Feature is a set of provisioning instructions
written in XML that tell SharePoint what to do when the feature is activated.
1.1.7. Testing and Debugging Your SharePoint Timer Job Attach To Process from the menu bar.
then select OWSTIMER.EXE from
1.1.8. Conclusion Timer jobs give you the flexibility to offload your long-running or scheduled
processes from your Internet Information Services (IIS) sites. Timer jobs are powerful because they can be configured to run on a specific schedule and can include any functionality
Create remote event receivers,Create an event receiver for an app for SharePoint
Prerequisites: In the procedures of this section, you extend an app for SharePoint by adding a remote
event receiver and enabling it to handle events that occur to list items in the app.
Add a remote event receiver 1. In Visual Studio, open Office/ SharePoint node.2. In the Templates pane, choose the Remote Event Receiver template.3. In the Name box, leave the default name (RemoteEventReceiver1), and then choose
the Add button.4. In the What type of event receiver do you want? list, choose List Item Events.5. In the What item should be the event source? list, choose Custom
List.suchas Announcements orContacts.6. In the Handle the following events list, choose An item is being added, and then choose
the Finish button.A web service is added to the web application to handle the remote event that you specified. A remote event receiver is added to the app for SharePoint and references the web service and the two list item events in the receiver’s Elements.xml file.
7. Perform the following steps to add a non-customizable list based on an existing list type of Custom List to the app for SharePoint. You'll insert items into that list later when you run the code.
8. Add code to file for the service of the remote event receiver (RemoteEventReceiver1.svc.cs).9. To debug an app for SharePoint that has remote event receivers and app event receivers, you
must open it on a computer that has local installations of Visual Studio and SharePoint. However, the event receivers for such an app will work on remote deployments after you deploy it.
Add an app event receiver
Chapter 2 of 82
Now that the app for SharePoint has a remote event receiver to handle list item events,
add an app event receiver that triggers when the app is installed.1. In Solution Explorer, choose the node for the app for SharePoint project.2. In the Properties window, set the Handle App Installed event to True.
A web service that's named AppEventReceiver.svc is added to the web application. This service contains a code file to handle the app-related events.
3. Add code to file (AppEventReceiver.svc.cs)
The app event receiver creates external files rather items in a SharePoint list because
the Handle App Installed event occurs before any SharePoint lists are available and
the app for SharePoint hasn’t loaded yet.
Run and test the event handlers To run and test the event handlers Choose the F5 key to run the project.
Create a work item timer job
when you have to process some items in SharePoint. Using Timer Jobs in only a half of the
answer. Find out how to process items using Work Item Timer Jobs in SharePoint
Processing items in SharePointAdvantages ofTimer Jobs are :
i. Executed outside the w3wp.exe process.
ii. Less prone to failures due to process termination.
iii. Allow us to move the load away from the Application Pool serving our solution.
When dealing with items you have to have some kind of queue which describes what should be
processed.
While implementing queues for Timer Jobs many people choose Lists for storage.
But it requires some additional work in creating and maintaining the queue List’s schema
There is however an easier way to work with item queues in SharePoint
Presenting Work Item Timer JobsWork Item Timer Jobs (SPWorkItemJobDefinition) are specialized types of Timer Jobs
designed for dealing with item queues.
Creating Work ItemsAt the base of every Work Item Timer Job is the Work Item: a unit of work that is picked up and processed by the Job when it executes. A work item can be added using the SPSite.AddWorkItem method parameters: gWorkItemId parameter which uniquely identifies the work item. (schdDateTime) determines when the item should be processed (gWorkItemType) contains the ID of the work item type. nUserId parameter which contains the ID of the user who requested the Work Item. rgbBinaryPayload and strTextPayload storing input values for the Timer Job and no need
for separate Lists.
Creating a Work Item Timer Job As mentioned before, Work Item Timer Job are specialized types of Timer Job, so they also
need a Feature to be deployed and a schedule to execute. The big difference is in the execution process. Where you would implement the Execute
method in a regular Timer Job, you use the ProcessWorkItem method to execute your logic. BatchFetchLimit property we specify how many items our Timer Job should process in a
single run. Important: One very important thing that you should implement correctly and test
thoroughly is cleaning up Work Items after they have been processed. Without this they would be processed every time the Timer Job executes over and over again.
Summary
Chapter 3 of 82
A. Work Item Timer Jobs are specialized type of Timer Jobs in the SharePoint platform, that
have been designed to work with queued items.
B. The mechanics behind the Work Item Timer Jobs contain all the plumbing required for
managing queues allowing you to focus on processing items.
C. Work Item Timer Jobs are a great alternative to using custom Lists as they require less
maintenance and are a part of the SharePoint platform.
Create SharePoint Designer workflows
Plan the type of workflow and associated forms (site, reusable, list, InfoPath), use custom actions, create workflow definition,
Learn to use Visio 2013 and SharePoint Designer 2013 to create and publish workflows to a
SharePoint 2013 site without needing any code.
1.1.1. Introduction
using Visio 2013, you can visually create a SharePoint workflow, export the workflow to
SharePoint Designer 2013, and then publish that workflow to a SharePoint site.
1.1.2. About creating SharePoint Workflows in Visio 2013 and SharePoint Designer 2013
Visio 2013 includes a SharePoint 2013 Workflow template that can be used to build
SharePoint 2013 workflows.
The SharePoint 2013 Workflow template is associated with three stencils: Actions,
Conditions and Terminators. To build a workflow, you need only to drag shapes onto the
drawing canvas in Visio 2013 to model the business logic behind the workflow.
Workflows in SharePoint Designer 2013 now include the notions of stages, loops, and
steps, can group a number of individual actions & conditions as a single unit to clearly
define the process.
Stage shapes:
A stage can contain any number of shapes and may include branching. However, there
can be only one path into a stage (and a step) and one path out. All actions in the
workflow must be contained by a stage.
Loop shapes:
Loops are a series of connected shapes that will execute as a loop, returning from the
last shape in the series to the first, until a condition is satisfied.
Step shapes:
Steps represent a grouped series of sequential actions. Steps must be contained by a
stage. A step shape must also have an Enter and Exit shape to define the paths in and
out of the shape.
1.1.3. Creating a workflow in Visio 2013
1. Open Visio 2013.2. Choose New.3. Under Template Categories, choose Flowchart.4. Under Choose a Template, choose SharePoint 2013 Workflow and then
choose Create.1.1.4. Customizing and publishing a workflow in SharePoint Designer 2013
1. Choose File, and then choose Add Item.2. To create a List Workflow, do the following:
a. Under Workflows, choose List Workflow.b. In the left pane under List Workflow, type a name for your workflow (My First
SP2013 Workflow) and select the list on the site that you want to publish the workflow to.
Chapter 4 of 82
c. In the Choose the workflow platform for the new workflow list, select SharePoint 2013 Workflow.
d. Choose Create.3. On the Workflow Settings tab, in the Manage group, choose Import from Visio.4. On the Visual Designer tab, in the Save group, choose Check for Errors.5. on the Visual Designer tab, in the Save group, choose Publish.
Create reusable workflows for content types,
1.1.5. Overview of workflows in SharePoint 2013:
SharePoint 2013 workflows are powered by Windows Workflow Foundation 4, which is
built on the messaging functionality that is provided by (WCF).
uses the Windows Workflow Foundation 4 activity model to represent a SharePoint-
based business process implemented declaratively by using XAML.
Workflow activities are invoked using loosely coupled web services that use messaging
APIs to communicate with SharePoint. These APIs are built on the messaging
functionality that is provided by (WCF).
Workflow Manager Client 1.0, SharePoint 2013, and SharePoint Designer 2013 each
provide significant parts of the new infrastructure
1.1.6. Platform architecture:
High-level architecture of the workflow infrastructure
1.1.7. Workflow subscriptions and associations:
SharePoint 2013 workflows move workflow processing onto external workflow hosts like
Microsoft Azure.
It was essential for SharePoint messages and events to connect to the workflow
infrastructure in Microsoft Azure.
A. Associations:
In addition, it was necessary for Microsoft Azure to connect the infrastructure to
customer data
Workflow associations bind workflow definitions to specific SharePoint scope, with
specific default values.
Chapter 5 of 82
The associations themselves represent a set of subscription rules that are stored in the
Microsoft Azure publication/subscription service that process incoming messages to
ensure that they are consumed by appropriate workflow instances. Workflows can be started either manually or automatically.
Manual workflows: Manual workflows are started when the PubSub service receives a StartWorkflow message. Auto-start workflows: Auto-start workflows are initiated by using an Add message to the PubSub service.
B. Subscriptions :
The natural complement to associations are subscriptions, which allow the workflow to
interact with associations. The workflow must create subscriptions on the Microsoft Azure
Service Bus using create methods and delete methods.
1.1.8. SharePoint workflow interop:
enables SharePoint 2010 workflows (which are built on Windows Workflow Foundation 3)
to be called from SharePoint 2013 workflows, which are based on Windows Workflow
Foundation 4.
Import and export Microsoft Visio workflows:
1.1.9. Transferring a workflow between SharePoint Designer 2013 and Visio
Professional 2013:
1.1.10.
Import a workflow from Visio:1. In SharePoint Designer 2013, in the Navigation pane, click Workflows.2. On the Workflows tab, in the Manage group, click Import from Visio.
Chapter 6 of 82
Chapter 7 of 82
3. In the Import Workflow from Visio Drawing dialog box, browse to and select the Visio Workflow Interchange (.vwi) file you want to use, and then click Next.
4. Type a name for the workflow, and then select the type of workflow you want it to be once it has been imported.
Your choices are:4.1. List workflow A workflow that is attached to a specific list. If you select this
option, you must choose the list to which the workflow will be attached.4.2. Reusable workflow A workflow that is attached to a content type, and is
therefore portable. It can be used by different lists on a SharePoint site. If you select this option, you must choose the content type on which the workflow will run.
5. Click Finish.6. The imported workflow appears in the SharePoint Designer full-screen workflow
editor.
1.1.11. Export a workflow to Visio:
you can use Visio to define the business requirements and then use round-tripping to
coordinate and approve changes.
"round-tripping": The ability to export a workflow back to Visio after it has been edited
in SharePoint Designer enables deeper collaboration between business users and
workflow designers.
1. In SharePoint Designer 2013, click Workflows in the Navigation pane.
2. On the Workflow tab, in the Manage group, click Export to Visio.
3. In the Export Workflow to Visio Drawing dialog box, name the file, select a location, and
then click Save. The exported file is saved as a .vwi file that can be opened directly in Visio
Premium 2013.
Export a workflow to a SharePoint solution
1.1.12. Overview of the workflow packaging capabilities of SharePoint Designer
2013
Learn how to package and deploy a workflow in SharePoint Server 2013 with SharePoint
Designer 2013.
Packaging: Saving a workflow as a template, it can then be imported into other
SharePoint Server 2013 environments and used without the need to redevelop the
workflow,Not all workflow types can be saved as a template .
workflow types that can be saved as a template:
1.List Workflow.
2.Site Workflow.
3.Reusable Workflow.
1.1.13. Packaging a workflow by using SharePoint Designer 2013
Chapter 8 of 82
The process for packaging a workflow involves saving the workflow to a template file
Click the Site Assets library to view the workflow template as shown in the
figure.
1.1.14. Deploying a workflow package to SharePoint 2013
You can deploy a workflow package to a another SharePoint farm or site But two items must be
fulfilled:
1. All workflow dependencies such as lists, libraries, columns, and content types must
already exist on the new site.
2. Each dependency must have the exact name of the source dependency.
Before you can deploy a workflow you must first export the workflow template from the source
SharePoint Server 2013 farm.
Chapter 9 of 82
Deploy a workflow solution
1. Open Internet Explorer and navigate to the SharePoint Server 2013 site collection where you
want to deploy the workflow.
2. Click Site Actions and select Site Settings.
3. In the Web Design Galleries section click Solutions.
4. Click the Upload Solution button to upload the solution as shown in the figure.
Activate the solution by clicking the Activate button as shown in the figure.
Chapter 10 of 82
After a workflow solution has been activated for a site collection, it is available as a feature for all sub-
sites.
Create and deploy Microsoft Visual Studio workflows
Create custom actions.
Learn how to model business processes whose requirements are not met by the existing library of workflow actions in SharePoint Designer by creating custom workflow actions in
SharePoint 2013.
You can develop these custom actions by using Visual Studio, and then package and deploy
them to SharePoint.
1.1.15. Core scenario for custom workflow actions
1. A non-technical information worker is using SharePoint Designer to author a workflow to model a document-approval process. However, in this company, the final step of the process is, upon final approval, to automatically dispatch the document to an external printer who prints and binds a specified number of copies of the document.
2. No workflow action that is included in SharePoint Designer 2013 supports dispatching a document to an external printer. Therefore, the company managers decide to invest in providing this custom action .
Chapter 11 of 82
3. Vendors expose printing web services. To capitalize, a developer creates a custom Send Files to Printer action, named SendFilesToPrinter. What the developer creates is a declarative workflow activity. The developer also, then, creates the workflow action to provide the drag-and-drop UI for the action in SharePoint Designer.
4. The developer packages both the SendFilesToPrinter workflow activity and the Send Files to Printer action in a SharePoint solution package (.wsp) file and deploys it as a site collection feature to the SharePoint farm.
5. After the feature is deployed and activated, the information worker sees the new custom action, Send Files to Printer, in the SharePoint Designer UI along with all of the normally included actions and can use it just like all the others.
1.1.16. Overview of custom actions
An action is a wrapper that abstracts the functionality of its underlying activity in SharePoint
Designer. At run time, the underlying activity, not the action itself, is executed in the Windows
Server AppFabric.
Like all actions, custom actions are "web scoped"—that is, they are activated at the level of the
SharePoint site collection, or SharePoint.SPWeb instance.
Actions are defined in XML definition files that have the .actions4 file name extension. The
underlying activity (or activities), on the other hand, are defined in a XAML file.
1.1.17. Writing custom activities in Visual Studio 2012 o You can use the item “workflow custom activity” in Visual studio to create a custom activity that
you can then import as a custom action in SharePoint Designer 2013.
1.1.18. Example: Create, package, and deploy a custom activity
create a workflow custom activity:
a) Visual Studio and creating a new SharePoint 2013 Project.
b) In the Add New Item dialog box, choose the Workflow Custom Activity.
c) toolbox nodes. Click the SharePoint 2013 Workflow node.
d) right-click the actions module icon in Solution Explorer, choose Add, and then choose either Add
Action (to add a new action4 file) or New Activity.
e) After you create your custom workflow activity, you can then package and deploy it.
f) Custom actions are packaged and deployed as SharePoint Features in SharePoint solution package
(.wsp) files.
1.1.19. Uptdating and deleting custom actions
After your custom action is deployed, you can update or remove it very easily. All you have to do is
open the activity project in Visual Studio, make the changes that you want, and then package and
redeploy.
Workflow Manager Client 1.0 (the multitenant workflow engine) is correctly configured.How to: Create a Sandboxed Workflow Action
Step 1: Create the SharePoint Project. In this step, you create a Visual Studio 2010 project that you can use to deploy and test your sandbox proxy.
I. Empty SharePoint Project.II. Deploy as a sandboxed solution.
Step 2: Create the Workflow Action Class. i. In this step, you create a class that contains your sandboxed logic.ii. Add a new public class .iii. Add the using Microsoft.SharePoint.Workflow.iv. add a public method that accepts an argument of type
SPUserCodeWorkflowContext and returns a value of type Hashtable.v. Within your method, implement your action logic.
Step 3: Create the Workflow Action Definition. I. In this step, you create a feature manifest file. This contains the markup that
references your class and defines your workflow action.II. Add New Item dialog box,Click Empty Element.
Chapter 12 of 82
III. Add a WorkflowActions element to the feature manifest.IV. Within the WorkflowActions element, add an Action element.V. Within the Action element, add a RuleDesigner element.
Create a workflow definition.
sample workflows to help illustrate how to create and implement SharePoint workflows in the
new Workflow Manager Client 1.0 framework.
SharePoint 2013 workflow: Call an external web service.
SharePoint 2013 workflow: Create a custom action.
SharePoint Workflow Development with Office Developer Tools for Visual Studio
a) Getting started – software:
you can now publish workflow apps to both the Office Store and the App Catalog. Actually, you can
create SharePoint 2013 workflows in solution projects too, but you’ll miss the remote development
feature that is available only with app for SharePoint projects.
b) Workflow projects created using Preview 2 of Office Developer Tools:
Better scalability and more reliable workflow app upgrade.
Optimized performance during workflow development and debuggin.
c) Walkthrough: Create a document approval and routing workflow app
d) In Visual Studio 2012, create a new App for SharePoint 2013 project, as shown in Figure 1.
Figure 1. Add new App for SharePoint 2013
project
e) Create two document libraries named Draft Documents and Published Documents as
customizable lists, as shown in Figure 2.
Chapter 13 of 82
Figure 2. Create new document library
f) Add these custom columns to both the Draft Documents and Published Documents libraries.
(Do the following for each library.)
f.1. Add a Person or Group list column and name it Approver.
f.2. Add a Choice list column and name it Document Status. Then add five choices to it: Draft In
Progress, Ready For Review, Approved for Publishing, Rejected, and Published.
(To set the choices, in the property grid, expand the Type property and click the ellipsis button
(…) on the Items property. Enter the values into the dialog box that pops up, as shown in
Figure 3.)
Figure 3. Customize list columns
g) Create a SharePoint list workflow named DocumentApprovalWorkflow, as shown in Figures 4 and
5.
Chapter 14 of 82
Figure 4. Add new workflow item
Figure 5. Configure basic workflow properties—name and type
h) Associate the workflow to the Draft Documents library, and opt to create a new history list and a
new workflow tasks list, as shown here.
Figure 6: Configure basic workflow properties—associate to lists
Chapter 15 of 82
i) Set the workflow association type to automatically start when an item is changed in the Draft
Documents library.
Figure 7. Configure basic workflow
properties—association type
Note: If you want to change the workflow association type after the workflow has already been
created, you can do so in the property grid (see Figure 8). (Workflow properties will appear in the
property grid when the workflow item is highlighted in Solution Explorer.)
Figure 8. Workflow properties in property grid
Chapter 16 of 82
j) If it’s not already open, double-click the workflow project item in Solution Explorer to open the
workflow designer. Figure 9 shows the workflow.
Figure
9. Empty workflow
k) Now let’s design the workflow logic. First we need to know the status of the document.
k.1. To retrieve this value, drag the LookupSPListItem activity from the toolbox onto the workflow
designer canvas. This activity returns a DynamicValue object, which contains the set of
properties (key-value pairs) from a specific SharePoint list item.
k.2. Configure the LookupSPListItem activity so that it returns properties from the “current item”
in the “current list” (see Figure 10). You can configure activities via the property grid while the
activity is selected in the canvas. Use the combo boxes provided in the property grid to make
these selections.
Chapter 17 of 82
Figure 10. Configure the LookupSPListItem activity
k.3. On the LookupSPListItem activity surface, click the Get Properties link. This automatically
does a few things for you (see Figure 11):
k.3.1. Creates a variable of the DynamicValue type and binds it to the out-argument of
theLookupSPListItem activity, named Result. This stores the properties from the list item
into the variable.
k.3.2. Adds a new activity named GetDynamicaValueProperties, and sets the newly
createdDynamicValue variable as the in-argument of this activity. This activity allows you
to extract the values of specific properties from the DynamicValue variable.
Figure 11. Configure LookupSPListItem activity—Get Properties
Chapter 18 of 82
l) On the GetDynamicValueProperties activity surface, click Define, and a dialog box appears,
which allows you to pick the properties to extract.
l.1. In the Entity Type list, select List Item of Draft Documents, as shown in Figure 12.
l.2. In the data grid, click Create Property to activate a combo box containing properties available
for list items in the Draft Documents library. Then select Document Status in the combo box.
Figure 12. Configure the GetDynamicValueProperties
activity
l.3. Add another row by clicking Create Property again, and then select Approver in the combo
box.
l.4. Click the Populate Variables link in the dialog box. This automatically creates a variable for
each row of the appropriate data type, and as the Assign To variable (see Figure 13).
Figure 13. Get Document Status and Approver properties
m) Now that we have the necessary list item values, we can check whether the document is Ready
For Review.
m.1. In the toolbox, drag the If activity onto the workflow designer canvas. (Hint: you can
search in the toolbox for quick filtering.)
m.2. Set the If condition to DocumentStatus.Equals(“Ready For Review”), as shown in
Figure 14.
Chapter 19 of 82
Figure 14. Configure If activity to check whether the document is "Ready For Review"
n) If the document is ready for review, then assign a task to the approver.
n.1. From the toolbox, drag a SingleTask activity onto the canvas and drop it into the Then area
within the If activity, as shown in Figure 15.
Figure 15. Add SingleTask activity
Chapter 20 of 82
n.2. Now assign the task to the approver. Click the Configure link on the activity surface. A dialog
box appears, allowing for basic configuration of the task properties. Set theApprover variable
to the Assigned To property, as shown in Figure 16. Click OK to save.
Figure 16. Configure the SingleTask
activity
n.3. At this point, you’ll notice a validation error on the SingleTask activity. Inspect it in the
property grid to see that the AssignedTo property has an error. Hover over the property name
to see a tooltip that indicates the property’s data type and a description of usage. We can see
that this property expects a String value, yet the Approver variable is of Int32 type (see
Figure 17).
Figure 17. Configure the SingleTask activity—AssignTo argument requires String type
Chapter 21 of 82
n.4. To correct this error, go ahead and append .ToString() to Approver, as shown in Figure 18.
You also could have done this directly in the configuration dialog box before. At this point, you
have configured a basic task that will send email to the Assignee (Approver in this case)
notifying him/her about a new task waiting for action.
Figure 18. Configure SingleTask
activity - AssignTo argument
o) Take a closer look at the property grid for the SingleTask activity. Scroll to the bottom, and you’ll
notice that variables were automatically created and set to Outcome and TaskItemId out-
arguments. Note the name of the Outcome variable—it should be something like outcome_0. We
will use this variable to check the outcome of the task in the next step, that is, whether the
approver approved or rejected the document.
(Note: The Outcome out-argument returns an Int32 value that corresponds to the index of the
outcome that the approver chose, that is, 0 for “Approved”, 1 for “Rejected”. These are the default
choice values within the out-of-the-box SharePoint site column named Task Outcome.)
p) To check the task outcome, let’s add another If activity to the workflow, and place it after
theSingleTask activity but inside the Then area. Set the If condition to outcome_0 == 0, to see
whether the task was approved (see Figure 19).
Chapter 22 of 82
Figure 19. Configure If activity to check whether the task was
approved
q) If the approver set the task to approved, then let’s update the document status to Approved For
Publishing and then copy it to the Published Documents library; otherwise, let’s set the document
status to Rejected.
q.1. Add the UpdateListItem activity to the Then area within this If activity.
q.2. Then configure it to update the “current item” in the “current list” by choosing the
corresponding values in the combo boxes in the property grid.
q.3. Next, click the ellipsis button (…) for the ListItemPropertiesDynamicValue property. A
dialog box appears, allowing you to specify the list item property that you want to update.
q.3.1. Set Entity Type to List Item of Draft Documents via the combo box.
q.3.2. In the data grid, click Create Property to activate a combo box containing properties
available for list items in the Draft Documents library. Then select Document Statusin the
combo box, and set its value to Approved For Publishing, as shown in Figure 20.
Chapter 23 of 82
Figure 20. Configure the UpdateListItem activity—approved status
q.4. Add a CopyItem activity into the Then area, below UpdateListItem, as shown in Figure 21.
Configure it to copy the “current item” from the “current list” to the Published Documents
library. Set Overwrite to true—we’re going to assume that all published documents come
from the Draft Documents library, thus no duplicate file names would exist within the same list.
Figure 21. Configure the CopyItem activity
Chapter 24 of 82
q.5. Now add an UpdateListItem activity into the Else area. This time, we want to set the
document status to Rejected. Figure 22 shows the completed workflow.
Figure 22. Completed
workflow
Create external connectors .
Chapter 25 of 82
Pluggable Workflow Services:
Pluggable workflow services provide a mechanism that allows external applications or
components to programmatically communicate with workflow instances currently running on
the server.
In Windows SharePoint Services 3.0, workflows could respond to a limited number of events.
To extend workflow capabilities, developers were required to have a workflow call an external
service through code, and then write a Web service that took parameters in order to update a
specific running workflow instance.
Pluggable workflow services provide a means for workflows to execute up to a specified point,
and then wait for information from an external process.
A workflow service developer needs to implement only two things:
1. The custom workflow service.
2. An event handler or Web service to receive the external event and respond by calling the
appropriate function in the custom workflow service, allowing the correct workflow to be
resumed.
Collaborative Workflow:
Deploy a workflow as part of a SharePoint solution or app .
1.1.20. Authoring basics for SharePoint workflows
Microsoft SharePoint 2013 provides two primary workflow development environments
Microsoft SharePoint Designer and Microsoft Visual Studio. both provide a fully declarative,
no-code or you can also use Microsoft Visio 2013 to structure your workflow logic by using
Visio 2013 shapes, and then import your logic into SharePoint Designer 2013.
Declarative workflows
This term means that instead of being authored in code and then compiled into managed
assemblies, the workflow is described (literally) in XAML and then executed interpretively
at run time.
The XAML is derived (or inferred) from the workflow building blocks. The building blocks
themselves are the visual workflow design objects in the designer toolbox-stages,
conditions, actions, events, and so on.
1.1.21. Decision tree: SharePoint Designer vs. Visual Studio
advantages of the workflow framework in SharePoint 2013:
A. is the ease with which information workers can use the no-code environment of
SharePoint Designer to create rich and powerful workflows.
B. a high degree of flexibility and customization is available in a declarative authoring
environment such as Visual Studio.
1.1.22. Comparing SharePoint Designer with Visual Studio
SharePoint Designer Visual Studio
Target users Information workers, business analysts,
SharePoint developers
Intermediate or advanced software
developers.
Difficulty level Familiarity with SharePoint Designer,
including the core workflow components,
such as stages, gates, actions,
conditions,loops
Familiarity with Visual Studio, including
software development concepts such as
event receivers, packaging and
deployment, and security
write custom
code
no no
create custom
actions
No. However, SharePoint Designer can
consume and implement custom actions .
Yes. However, the underlying activities,
not their corresponding actions, are used.
As a part of a
solution or app
no yes
Chapter 26 of 82
reuse of
workflows
A workflow can be used only by the list or
library on which it was developed.
However, SharePoint Designer provides
reusable workflows.
A workflow can be written as a template
so that after it is deployed, it can be
reused and associated with any list or
library.
Can use Visio yes no
Deployment Deployed automatically to list, library, or
site on which they were created.
Create a SharePoint solution package
(.wsp) file and deploy the solution
package to the website.
Debugging no yes
1.1.23. Developing workflows using Visual Studio
Unlike earlier versions, workflows in SharePoint 2013 are entirely declarative. Built
now on Windows Workflow Foundation 4, Visual Studio provides a visual workflow
designer .
Your workflow is then packaged and deployed as a SharePoint Feature.
Perhaps the most significant change for Visual Studio developers is that custom
workflows are no longer compiled and deployed as .NET Framework assemblies.
Furthermore, SharePoint 2013 no longer uses Microsoft InfoPath forms; instead, forms
generation relies on Microsoft ASP.NET forms.
1.1.24. Enabling on-premises workflow debugging you need to temporarily allow the Workflow Manager Tools to access your system through the firewall.
1. In Control Panel, choose System and Security, Windows Firewall.2. In the Control Panel Home list, choose the Advanced Settings link.3. In the left pane of Windows Firewall, choose Inbound Rules.4. In the Inbound Rules list, choose Workflow Manager Tools 1.0 for Visual Studio 2012 -
Test Service Host.5. In the Actions list, choose Enable Rule.6. On the properties page of your SharePoint project, choose the SharePoint tab, and then select
the Enable Workflow debugging check box.1.2. Upgrade a SharePoint 2013 Visual Studio workflow .
xcx1.3. Plan the type of workflow and associated forms .
xcfgfgfgf
fgf
Chapter 27 of 82
Chapter 7 Create Office apps (10‒15%)
Plan and design applications
Choose a hosting location.
Learn about the different ways that you can host the components of apps for SharePoint.
What to think about when choosing your development pattern SharePoint-hosted apps, or apps where all components are hosted on either an on-premises or Office 365 farm.
Provider-hosted apps for SharePoint include components that are deployed and hosted outside the SharePoint farm.
They are installed to the host web, but their remote components are hosted on another server. Match your hosting pattern with your development goals
Your requirements Recommended Hosting pattern
Example
Work with and provision new SharePoint entities exclusively
SharePoint-hosted
An app that includes a people picker control and that stores information about SharePoint users in a SharePoint list
Use existing SharePoint entities and interact with external (non-SharePoint) web services
Provider-hosted An app that gets customer addresses from an existing SharePoint list in the host web and uses a mapping service in a web application to display their locations
Provision new SharePoint entities and interact with external web services
Combined SharePoint-hosted and provider-hosted
A mapping app that provisions a SharePoint list on the appweb so that it can store latitude and longitude coordinates for addresses that are supplied by the user or pulled from an existing SharePoint list
What to think about when choosing your hosting pattern for provider-hosted apps SharePoint-hosted apps have a fixed hosting pattern:
OAuth or the cross-domain libraryhow the app will get authorization to interact with SharePoint. Provider-hosted apps give you two choices: the JavaScript cross-domain library and OAuth.The cross-domain library lets you interact with more than one domain from the remote components of your app through a proxy. The cross-domain library is also convenient whenever:
If client-side code and the permissions of a user who is signed in to SharePoint are sufficient you are making remote calls through a firewall.
OAuth is an open protocol for authorization that enables secure authorization from client applications (desktop, web, and mobile applications) in an easily manageable way. OAuth is required whenever you are calling into SharePoint from a remotely hosted web application that can’t use client-side code (HTML + JavaScript) exclusively.
OAuth with on-premises SharePoint farmsIf you are using an on-premises deployment of SharePoint 2013, you can use OAuth, but you will have to choose between creating high-trust apps and using an Office 365 tenancy.
Combine provider hosting and SharePoint hosting
Creating provider-hosted apps that don’t open from SharePoint
Chapter 1 of 82
Specify a starting location.
locationRibbon Custom ActionMenu Item Custom ActionApp Part_layouts/15/appredirect.aspx
Specify a licensing model.
Learn how you can use the app license framework for apps for Office and SharePoint to verify
and enforce legal use of your apps that are downloaded from the Office Store.
Using the licensing framework to control app usage for apps for Office and SharePoint
gives you a way to include code in your apps to verify and enforce their legal use.
The app license framework itself does not enforce app licenses. It's a structure in which you
can add code to your apps to retrieve and then act on license information.
What are app licenses?
An app license is a digital set of verifiable information stating usage rights of an app for
Office or app for SharePoint:
The information is verifiable in that you can query the Office Store to check on an app
license validity.
These usage rights include whether an app is for purchase or is free, whether the app is
available on a per-user or site basis, and whether the app is a trial or full version.
How you can use license information in your appsThe following figure shows the app license query and validation process for apps for SharePoint.
1. The user launches the app from within SharePoint.2. This launches the app code in the cloud.3. When the app needs to verify a user’s app license, it uses server-side code to query SharePoint,
via the client object model, for the app license token.4. It then passes that token to the Office Store verification service.5. The verification service returns whether the license token is valid, and if it is, also returns the
license properties.6. The app can then take action, based on the validity of the license and its properties.
Chapter 2 of 82
SharePoint 2013 hosted App License check
How do you manage/enforce licensing on a fully SharePoint hosted app with JavaScript only?
You need a couple of things:
1. JavaScript that checks for the license.
2. Landing pages, telling you that your license has expired or is invalid.
3. An app that helps you creating test keys for testing your App with licensing.
Specify permission requirements.
Authorization and authentication for apps in SharePoint 2013
I. App authentication in SharePoint
II. Authorization policies: user-only policy, user + app policy, or app-only policy
III. OAuth 2.0 in SharePoint 2013
IV. When is OAuth used?
V. Access tokens
VI. App permissions and app permission request scopes
Select a user experience for apps.
1.1.1. High-level overview of app UX in SharePoint 2013 Figure App UX main scenarios and options
Chapter 3 of 82
In choosing your design, you should fundamentally consider which parts of your app are hosted in SharePoint and which are not. You should also consider how your app interacts with the host web.
1.1.2. App UX scenarios in cloud-hosted apps
The following UX resources are available for cloud-hosted apps in SharePoint 2013:
1. Chrome control: The chrome control enables you to use the navigation header of a
specific SharePoint site in your app without needing to register a server library or use a
specific technology or tool. To use this functionality, you must register a SharePoint
JavaScript library through standard <script> tags.
2. Stylesheet: You can reference a SharePoint website’s style sheet in your app for
SharePoint and use it to style your webpages using the available classes. In addition, if
the end users change the SharePoint website’s theme, your app can adopt the new set
of styles without modifying the reference in your app.Figure 2. App UX resources for cloud-hosted apps
1.1.3. App UX scenarios in SharePoint-hosted apps
Chapter 4 of 82
the user experience is less likely to change very much when users move back and forth between the
host web and the app web.
When the app is deployed, the app web takes the style sheet and theme from the host web. You can
still use the chrome control and style sheet in a SharePoint-hosted app, but the most significant
difference with cloud-hosted scenarios is the availability of the app template.
The following UX resource is available for SharePoint-hosted apps:
App template: The app template includes the app.master masterpage.
1.1.4. Scenarios for connecting the app UX to the host web
The following UX resources are available to connect your app UX to the host web:
1. Custom actions: You can use custom actions to connect the host web UX with your
app. There are two types of custom actions: Ribbon or ECB. A custom action can send
parameters such as the list or item on which it was invoked to a remote page.
2. App parts: You can include some of your app user experience in the host web by using
app parts. The app part is available in the Web Part gallery in the host web when you
deploy the app.
Users can add the app part to a page by using the Web Part Adder control.
Create applications
Create provider-hosted applications.
Learn how to create a basic provider-hosted app for SharePoint with the Office Developer Tools
for Visual Studio 2013, how to interact with SharePoint 2013 sites by using the SharePoint
CSOM, and how to implement OAuth in an app for SharePoint.
1.1.5. Prerequisites for building a basic provider-hosted app
i. An Office 365 Developer Site.
ii. Visual Studio 2013 installed on your developer computer.
iii. Office Developer Tools for Visual Studio 2013 installed on your developer computer.
1.1.6. Create and deploy a provider-hosted app for SharePoint solution
Chapter 5 of 82
A provider-hosted app for SharePoint consists of both an app for SharePoint that is
deployed directly to a SharePoint 2013 site and a separately deployed web application.
1. Create an App for SharePoint 2013 project
2. In the New Project wizard, Office/SharePoint node.
3. Choose Apps, and then choose to create an App for SharePoint project.
4. Enter the URL for your Office 365 Developer Site. Select the Provider-hosted hosting option,
and then choose the Next button.
5. choose ASP.NET Web Forms Application. Choose the Next button.
6. to authenticate?, choose Use Windows Azure Access Control Service (for SharePoint
cloud apps).
7. In the wizard, choose Finish, Two projects are created in the Visual Studio 2013 solution, one
for the app for SharePoint and the other for the ASP.NET web application.
http://msdn.microsoft.com/en-us/library/fp142381.aspx
1.1.7. Retrieve data with the SharePoint client object model (CSOM) 1. Open the AppManifest.xml file. On the Permissions tab, specify the Site Collection scope and
the Read permission level.2. Add HTML and ASP.NET controls inside the <body> tag of the Pages/Default.aspx file of your web
application.3. Add declarations to the Default.aspx.cs file of your web application.
http://msdn.microsoft.com/en-us/library/fp179936.aspx
1.1.8. Using REST Services with a Provider Hosted App in SharePoint 2013
http://blogs.technet.com/b/speschka/archive/2013/04/11/using-rest-services-with-a-
provider-hosted-app-in-sharepoint-2013.aspx
create auto-hosted applications,
create SharePoint-hosted applications,
http://msdn.microsoft.com/en-us/library/fp142379.aspx
apply chrome control
http://msdn.microsoft.com/en-us/library/fp179916.aspx
Package and deploy apps
3.1. Package an application,
3.2. publish to Corporate Catalog,
3.3. publish to SharePoint store,
3.4. publish to Microsoft Azure,
3.5. manage trust relationship with other providers
Chapter 6 of 82
Manage the App Life Cycle
3.6. Upgrade an application,
3.7. remove an application,
3.8. manage licensing,
3.9. manage usage tracking
---
Chapter 7 of 82