Professional Documents
Culture Documents
Hands-on with
SharePoint 2010:
Deep Diving With the Experts
Introduction .................................................................................................................................... 3
Ricky Spears................................................................................................................................. 3
Eric Eaton .................................................................................................................................... 3
David Fisher ................................................................................................................................. 4
Jeremy Luerkens ......................................................................................................................... 4
Tony Bierman .............................................................................................................................. 4
What’s New in SharePoint 2010 Lists? (Audience: All) ............................................................. 5
The New Approval Actions in SharePoint Designer 2010 Workflows (Audience: All) ........... 9
The New Chart Web Part in SharePoint 2010 (Audience: All) ................................................. 19
2
SharePoint 2010 * Windows PowerShell = Disaster Recovery (Audience: IT Admins) ...... 38
SharePoint 2010’s New Granular Content Restore Capability (Audience: IT Admins) ........ 49
Creating a Custom Ribbon Tab in SharePoint 2010 (Audience: .NET Developers) .............. 63
This white paper is a compilation of SharePoint 2010 articles that have been written by our
experts as they have dived deep into the feature-set of the new version of SharePoint. As one
of Microsoft’s leading SharePoint partners, SharePoint Solutions has had access to early bits of
SharePoint 2010 and all of these articles were written based on the Technical Preview version
which was released to selected Microsoft partners in July 2009.
We believe that this set of articles is unique in that SharePoint Solutions is the only company to-
date to document in detail, and based on extensive hands-on work, some of the important new
SharePoint 2010 features prior to the release of the public beta in November 2009.
Ricky Spears
Managing Director, Training Division and Senior Instructor/Author
Eric Eaton
Senior SharePoint Infrastructure Engineer, Instructor, Consultant
Jeremy Luerkens
Software Production Manager and Senior Engineer
Tony Bierman
Managing Director, Commercial Software Division
In my opinion, lists and libraries are the heart and soul of SharePoint. When I first installed the
Microsoft SharePoint 2010 Technical Preview, the first thing I did was create a new list just to
see what the most obvious changes were. Note: This article and all screenshots are from the
Technical Preview and things may change before SharePoint 2010 is released to the public.
I use custom lists for lots of things, so I started by creating a new custom list. The creation
process wasn’t very different from the process in SharePoint 2007.
Very quickly I noticed that the familiar toolbar at the top of the list had been replaced by a
ribbon, similar to the one in the Office 2007 applications.
The default view of the ribbon after creating a list is the List ribbon. Although I’m used to using
the menus, the ribbon allowed me to more quickly create views, create columns, change list
permissions, go to list settings, and much more.
To add a new item to the list, I switched to the Items ribbon and clicked the New Item button.
Instead of switching to a new page to add my new item, a new form appeared in front of my list
and it appeared the lights were dimmed on SharePoint and new form had a spotlight on it. The
new item form had a ribbon itself with quick access to Cut, Copy, and Paste commands, a button
to attach a file, a spell check button, as well as the expected Save and Cancel buttons.
When I checked the box beside one of the items I added in my list, I saw options to work with
that item in the Items Ribbon. From here I could view the item, edit it, delete it, and change its
permissions. I could have done more if my simple custom list had more functionality.
One of the things that has always frustrated me is that I haven’t had a good way to keep people
from entering the same item multiple times in a list. In the Additional Settings section for the
Single line of text, Number, Currency, Date and Time, Lookup, Person or Group, Business data,
and Managed Metadata there is a setting for Allow Duplicate Values.
If you select to not allow duplicate values for a particular column, and you try to add a new item
with an existing value in that column, you will receive an error and have to fix the error to
proceed.
In the past, we didn’t have any way to validate a user’s input in lists and libraries. When you add
new columns of type Single line of text, Choice, Number, Currency, or Date and Time you will
see a section called Column Validation. Here you can enter Excel type formulas that must
evaluate to True before the user can add the item to the list.
If the user’s input doesn’t validate according to your formula, the User Message you entered will
be displayed to the user.
There are also validation settings on the list itself that work similar to the validation settings on
the columns.
Metadata Navigation
In SharePoint 2010 we’ll be able to better locate our data based on its metadata. This can be
configured separately on each list and is a whole other blog post in itself. I thought you might
want to see a screenshot of the settings though, so here you go!
In the past, if you wanted to change the way a form looked in SharePoint for entering new
information or editing information, you had to create a whole new form using SharePoint
Designer. Now, all those forms are InfoPath forms and selecting the option to edit the form
opens it in InfoPath where you can make any changes you want, then just republish the form.
Conclusion
I’m sure that as we all dig deeper SharePoint 2010 we’ll find even more goodness there, but
these were the first things that caught my eye and I wanted to share these with you. I think
these are all significant advances over lists in SharePoint 2007.
SharePoint 2007 came with 23 out-of-the-box actions to fit many of the most common tasks
needed in workflows. SharePoint 2010 comes with 44 out-of-the-box actions. All the original
actions are still there, but you now have 21 more! Note: This article and all screenshots are from
the Technical Preview and things may change before SharePoint 2010 is released to the public.
In SharePoint 2007, if you wanted to get approval from a user for something, you usually had to
use the Collect Data from a User action, store a reference to the task ID for the task that was
created, and then lookup the user’s input later in your workflow as needed. Microsoft has
streamlined this process in SharePoint Designer 2010 with the actions for Assign Item for
Approval, Assign Item for Feedback, and General Task Process. In this article, we’ll take a look at
how these three actions work.
The first thing you will notice when you add any of these three actions to your workflow is that
in the Editor, they all look identical. In the following screenshot I have added an Assign Item for
Approval action to Step 1, and Assign Item for Feedback action to Step 2, and a General Task
Process action to Step 3.
Let’s work our way around this page to explain what each section does.
Task Information
In the Task Information section there are only two options, you can change the name of the
Approval Process and the Owner of the task.
When you change the Name here it also changes the name in the workflow editor.
Task Outcomes
The Task Outcomes section, you can define the various outcomes for this particular process. If
you selected the Assign Item for Approval action, you will already have the options of Approved
and Rejected listed here.
If you want to add other options, you can click the New button to add a new option. In the
example here, I have added a Skipped option.
The Task Form Fields section allows you to collect other information in the task form. For
example, if something is approved or rejected, you probably want the person who is doing the
approving or rejecting to enter some notes about why they chose to approve or reject it.
By clicking the New button, you can add your custom data fields to the form. There is a short
wizard that will walk you through the process.
Settings
If you check the box for Only allow task recipients and process owners to read and edit
workflow tasks then those are the only people who can do those activities. Do you remember
when you could set the process owner in the Task Information box? Well, this is where that
process owner is used.
Customization
I’ve saved this section for last because it is probably the most complex of the five configuration
sections.
Clicking on the Return to Workflow link simply closes the Approval Process editing window and
returns you to the workflow Editor.
If you click on Change the completion conditions for this task process you will be taken to the
Check Exit Conditions section where you can see the underlying conditions that are part of this
activity. This is probably where you begin to see how powerful these new Approval Actions
really are. Here is a screenshot of the default page without making any changes:
If you click on Change the behavior of a single task you will be taken to a place where you can
see and change the behaviors for On Task Assigning, On Task Pending, On Task Expired, On Task
Deleted, and On Task Completed. Within each of these, you can add your own conditions,
actions, and steps. Here is a screenshot of the default page:
If you click on Change the behavior of the overall task process you will be taken to a place
where you can see and change the behaviors for On Approval Started, On Approval Running, On
Approval Canceled, and On Approval Completed. Once again, within each of these, you can add
your own conditions, actions, and steps. Here are screenshots of the various sections of the
default page:
Item to Be Approved
You probably expect that the only item on which you can perform the Approval action is the
current item. However, if you click on Current Item, you can change that to any list or library
item you want.
Another thing that I found frustrating in SharePoint 2007 was that I couldn’t customize the task
and emails that they sent. When you click on the link in SharePoint 2010 to add users, you get a
dialog box where you can customize task request, including the title and body that can include
lookups. You can even add serial and parallel recipients and have multiple assignment stages.
Well, there you have it. You’ve gotten a general overview of the options for the new Approval
Actions in SharePoint Designer 2010. If you are overwhelmed, I’m not surprised. In this post,
we’ve only just barely scratched the surface of the great things you can do with SharePoint
Designer Workflows in SharePoint 2010. You’ll probably need to take a class to learn it all.
I may have a new favorite web part in SharePoint 2010—at least it’s my favorite for a while. I
am a bit of an Excel fanatic. I love drilling down into data to gain obscure business intelligence. I
love pivot tables, and I love graphs—although I’ll admit I’m much better at pivot tables than I am
graphing. It’s easy to get caught up in displaying your data in Excel—it becomes much more like
playing Excel than working with Excel. The new Chart Web Part is one of those fun web parts
that you can get caught up in playing with but it also solves the common business problem of,
“How can I quickly display a chart of some data on my SharePoint page?” Note: This article and
all screenshots are from the Technical Preview and things may change before SharePoint 2010 is
released to the public.
Excel services is a great way to render charts in SharePoint – just set up the chart in Excel and
then add an Excel Services web part to display the named chart from your published
spreadsheet. But with the Chart Web Part, you can not only chart information from your Excel
Services spread sheets, but also from any SharePoint list. And best of all, you configure
everything in your browser!
You’ll find the Chart Web Part in the Miscellaneous category and you add to your page just like
you would any other web part by selecting it and clicking the Add button.
With most web parts, you expect to configure them in the tool pane, although you can certainly
do that by clicking on Modify Shared Web Part, you will probably want to use the wizards to
configure it. You can access the list of wizards by clicking on Wizard List.
There are two wizards: one to Customize Your Chart, and one to Connect Chart to Data. We’ll
begin by using the Connect Chart to Data wizard and then we’ll customize our chart later.
The first step in the wizard is to choose a data source. Notice that you have the options to Get
Data From Another Web Part, Connect To a Site Definition List, Connect to Business Data
Catalogue, and Connect to Excel Services. This is a nice set of options. I have some Sales Data in
a SharePoint list and that’s what I want to chart, so I’ll select the option to Connect to a Site
Definition List.
In the second step of the wizard, I select the site where my data is stored and the list. Both of
these are displayed in drop-down list boxes and I can select lists and libraries anywhere in my
site collection—not just the one I’m currently working in, which is a very nice feature.
Here is what the SharePoint list looks like if you view the default view directly:
For this blog post I used 4 series that were each set up to display a unique quarter (Q1 Sales, Q2
Sales, Q3 Sales, and Q4 Sales). You can’t see these all at once, so I’m not adding screenshots. I
didn’t add any other Data Point fields, Formulas, or change the Advanced Properties. At this
point, I had finished the Connect Chart to Data wizard. I could see my data displayed in the Chart
Web Part.
This is the wizard that will allow you to change the way your chart looks. Once again, you have a
very impressive number of options here.
The first step is to select a chart type. I counted 158 different types of charts! You have two
dimensional and three dimensional charts in types of column, bar, area, line, point/bubble,
financial, pie, radar, polar, Gantt/range column, range, error bar, box plot, funnel, and pyramid. I
know that with this set of options, it’s kind of boring, but I selected the Column with Perspective
as my chart type. It just seemed appropriate for this kind of sales data.
Advanced Properties
The only thing I haven’t shown you yet is the Advanced Properties. If you click on this link, you
can view a properties dialog where you can change various properties of the image itself like
antialiasing, shadows, border line colors, and much more.
Microsoft is taking a bit of the chore of designing workflows off of designers and letting business
users define their own workflow layout in Visio 2010 before exporting to SharePoint Designer to
associate it with a List or Site. This allows business users to use a familiar graphical tool to define
the steps in the workflow themselves instead of having to communicate their needs to designers
or developers through a requirements document. The resulting Visio workflow can be used as
the actual initial building block in the workflow.
Visio includes a brand new template aptly called Microsoft SharePoint Workflow that includes
Condition and Activity shapes specific to SharePoint workflows.
Note: This information is currently based on Technical Previews of both Visio 2010 and
SharePoint Designer 2010 and both are subject to change in the Beta version due out later this
year. It is also important to note that Designer connects directly to the SharePoint site and
retrieves a list of available conditions and activities currently installed on the site including any
created in Visual Studio and any 3rd party installed solutions, whereas Visio does not; the list
available in Visio is static in this preview version. The ability to connect to the target site in Visio
would be a great addition and would help to allow business users to build a more complete
workflow ready for installation into a SharePoint site.
Creating a workflow will come naturally to users familiar with creating charts in Visio using drag
and drop from the Shapes tabs and connecting them on the workspace, with the only difference
being the SharePoint specific shapes. Below is an example of a simple workflow created in Visio
2010.
After completing the workflow, it is necessary to check it for errors in logic. Visio 2010 includes
the "Check Diagram" option from the Process tab of the Ribbon.
By default, the Check Diagram feature includes the "SharePoint Workflow" option as the rule
base to check the workflow against. Clicking on "Check Diagram" will result in Visio checking the
logic against SharePoint's rules and will either notify that no errors where found or give a list of
errors in the Issues Window below the workspace. Clicking on an issue will highlight the
offending object making it easier to determine the cause and fix the problem.
After successfully checking the workflow, you now must export it to the file system so that it can
be imported into SharePoint Designer. On the Process tab of the Ribbon are the Import and
Export buttons. Import allows you to open workflows created in SharePoint Designer for graphic
representation and documentation. Since it is possible to create a workflow in Designer that
Exporting is as easy as clicking the Export button and choosing a filename and location. Visio
2010 will save the workflow with a .vwi extension. By simply renaming this file with a .zip
extension you can open it and reveal the following 4 embedded files.
[Content_Types].xml
This file simply stores a list of the extensions of the files embedded in the .vwi file.
workflow.vdx
This is the Visio definition file for the workflow including file properties and layout details for the
workspace. When building a workflow in Designer, you will notice each condition or activity
includes a sentence where you set properties for its parameters. This file contains the text for
those sentences for use when importing the workflow into Designer.
workflow.xoml
Designers and developers familiar with creating workflows in SharePoint Designer will be
familiar with this file. It is an XML representation of the workflow including all conditions and
activities and their parameters. Although Visio does not include shape data on the workspace,
when exporting the workflow, the appropriate parameters will be included in this file. When
importing the workflow into Designer, it uses this file to get the logic for the workflow as well as
all of the parameters and values for each condition and activity. The exported file will have the
value {x:Null} set for each parameter since there is no way to set these in Visio.
Here is a sample .xoml file as created when exporting the workflow shown above. The
SequenceActivity section has been highlighted to show how the workflow logic including the
conditions and activities is written to this file.
<ns0:RootWorkflowActivityWithData x:Class="Microsoft.SharePoint.Workflow.ROOT"
x:Name="ROOT" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/workflow"
xmlns:ns1="clr-
namespace:Microsoft.SharePoint.WorkflowActions.WithKey;Assembly=Microsoft.SharePoint.Work
flowActions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=null"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ns0="clr-
namespace:Microsoft.SharePoint.WorkflowActions;Assembly=Microsoft.SharePoint.WorkflowActi
ons, Version=14.0.0.0, Culture=neutral, PublicKeyToken=null">
<ns0:RootWorkflowActivityWithData.WorkflowFields>
<ns0:WorkflowDataField Name="__item"
Type="Microsoft.SharePoint.Workflow.SPItemKey" />
<ns0:WorkflowDataField Name="__context"
Type="Microsoft.SharePoint.WorkflowActions.WorkflowContext" />
</ns0:RootWorkflowActivityWithData.WorkflowFields>
<ns0:OnWorkflowActivated.CorrelationToken>
</ns0:OnWorkflowActivated.CorrelationToken>
</ns0:OnWorkflowActivated>
<SequenceActivity x:Name="ID3">
<IfElseActivity x:Name="ID4">
<IfElseBranchActivity x:Name="ID5"
Description="ShapeGuid={5C21D244-2AB1-4447-A2BA-CE6431839784};PageId=0;ShapeId=4;">
<IfElseBranchActivity.Condition>
<RuleConditionReference ConditionName="__Rule_ID5"
/>
</IfElseBranchActivity.Condition>
</IfElseBranchActivity>
<IfElseBranchActivity x:Name="ID7">
</IfElseBranchActivity>
</IfElseActivity>
</SequenceActivity>
</ns0:RootWorkflowActivityWithData>
This file defines the rules used when checking the workflow for errors.
SharePoint Designer leaves behind the old look and feel of FrontPage; in 2010, it fits right in with
the Office suite. In this technical preview, there are a few pieces that are not as obvious to
access and even completely hidden and this is bound to get under the skin of technical designers
and developers. However, my thoughts are that most of them may likely make their way into
the public release due out by the time of this writing. I will only discuss those features
associated with workflows in this article.
To see the list of workflows for the loaded site, simply click Workflows on the left Navigation
bar.
After importing the previous workflow shown in Visio, you come to the Edit screen for the
workflow where you can define the values for the parameters as well as add additional
conditions and activities.
The Ribbon is context specific and now contains buttons for building and publishing the
workflow. The Manage section includes buttons for Checking for Errors, Publishing the workflow
and exporting as a .vwi file to Visio.
The Modify section includes buttons for moving activities around in the workflow as well as an
"Advanced Properties" button where you can set the parameters for the selected condition or
activity. This allows you to set values for the parameters directly as opposed to using the
standard DesignerType. Clicking on the parameter in the sentence allows you to set the values
using the DesignerType pop up window.
The Insert section includes buttons for editing the logic of the workflow; inserting steps,
conditions and actions, running sections in parallel and adding steps that use Impersonation to
run as the workflow author.
Lastly, the Variables section includes a Forms Parameters button to define parameters used to
gather data from the user on the Initiation and Association forms when the workflow runs. It
includes the Local Variables button for creating variables for use within the workflow and that
can be accessed as lookups on the workflow. The Variables section also includes an Association
Columns button which allows you to automatically create columns on a list when the workflow
is associated with it. The purpose of this is to make sure that these columns exist if the workflow
depends on them for setting or gathering data.
Clicking on the Publish button validates the workflow for errors, saves the .xoml file and makes
the association with the list in the content database. One of the options missing that developers
in particular may miss is the fact that there is currently no way to view the .xoml in Designer as
there was in 2007. You will have to Export to Visio to produce the .vwi file to get access to the
xoml code. If you make any changes to it, you will need to import the .vwi back into Designer.
When Publishing the workflow I have come across some errors in validation associated with the
DesignerTypes in 2010. Some changes have been made in the DesignerTypes that will be the
topic of another article. Workflows built in Visio 2010 should not be affected, but any existing
conditions or activities built in Visual Studio will.
The next logical step that does not show up in the Technical Preview of Visio 2010 is the ability
to create custom conditions and activities in Visual Studio and import them into Visio as well as
the addition of shape data for the shapes in Visio 2010. With this new template addition,
business users should enjoy the ability to create their own workflows knowing that what they
build will actually become the core of the workflow they will end up using on the SharePoint
site.
There were many options for disaster recovery with WSS 3.0 and MOSS 2007. The native tools
all had significant advantages, and unfortunately, disadvantages. Methods that offered the best
protection against full-scale disasters offered little to no granular protection against more
common ‘accidental deletion’ moments. STSADM, the SharePoint command-line administration
tool, offered the only native way to schedule backups by means of simple batch files – but it was
painfully slow and many times marked the site collection read-only as it worked.
Because of these limitations, many organizations either used multiple types of backups to
protect against different scenarios, or relied on third-party products to fill the gaps (or even to
completely replace the native tools).
With the new SharePoint 2010 functionality, these limitations no longer pose significant
obstacles. With enhancements to Central Administration’s backup / restore tools and the
addition of Windows PowerShell cmdlets to our command-line tool belt, it is now possible to
cover most issues and / or scenarios with a single disaster recovery scheme that protects your
SharePoint configuration and data from both granular, accidental deletions and true large-scale
disasters.
Big Picture
This post is specifically addressing the backup and recovery of SharePoint configuration and data
– not A.D. or other directory providers, your server environment, branding, and programmatic
customizations such as features and solutions. The strategy for protecting those elements will
vary greatly depending on your organization’s overall disaster recovery strategy which may
include traditional tape backup, virtual machine snapshots, server imaging, off-site replication,
shared software installation points… At the very least, you should have a copy of all installed
solution packages stored and backed up with the rest of your installation media.
Obviously, to offer any kind of protection against large or small scale disasters, backups must
occur regularly and automatically. To schedule backups of SharePoint data, an administrator
has two options – SQL and PowerShell. SQL does not offer full configuration backup on its own
– but PowerShell does.
In fact, SharePoint 2010 adds about 300 new cmdlets that provide a much more flexible,
interactive, and granular tool for SharePoint than STSADM ever did. Several of these cmdlets
provide the same backup functionality available manually through the Central Admin site,
including the ability to pick and choose which farm elements to backup / restore. An
Let’s take a look at the Central Admin ‘Backup and Restore’ page to see what is possible here.
Login to your SharePoint server, and go to Start > Administrative Tools > SharePoint 4.0 Central
Administration.
Click on the first displayed link, ‘Perform a backup’, and you’ll see a tree view of all farm
elements. Notice that this includes the configuration database, web application setup, content
databases, service applications, user profiles… Pretty cool, eh?
Go to Start > Administrative Tools > SharePoint 4.0 Management Console (SMC). (This may
take a moment to load, don’t get impatient.) Type the following to display the components
hierarchically by name: Backup-spfarm -showtree.
To see some basic help text on the usage, type: backup-spfarm -?. (A complete
reference of the –detailed text of all SharePoint PowerShell cmdlets is being built at
http://sharepointsolutions.com/sharepoint-help/groups/sharepoint-2010-powershell-
reference/home/).
If your datasets are too large to do a full farm-level backup every day, you may wish to do this
weekly and then back up only the content nightly. To create a backup of just a content database
type the following command in the SMC:
Backup-spfarm –directory \\fileserver\backupshare -item “name as
listed in tree above” –backupmethod full
In the background, these backup commands are using different backup methods to protect
different components. For instance, the content is backed up via a remote SQL database backup
statement. A complete log of the backup attempt is kept in the ‘spbackup.log’ file in the backup
directory you specified in the command above. If there are any warnings or errors, the SMC will
give a generic message that ‘The backup job failed…’ That doesn’t mean the entire job failed,
but you will have to check the log file to find out where the problems were encountered.
Now that you know how to form the basic SharePoint PowerShell commands, the next step is to
schedule them. This process is made up of a couple of steps.
If you need to clear previous backup directories to conserve disk space, you can do this in your
ps1 PowerShell script, as shown here.
Here are the steps to use the Task Scheduler functionality in Windows 2008 Server to schedule
your script to run on a daily basis. (If you are using Win2k3 as your OS, the steps are similar but
they would be done in the older style Scheduled Tasks tool.)
Go to Start > All Programs > Accessories > System Tools > Task Scheduler, and click on the
Create Basic Task… link on the right side.
If you have multiple PowerShell scripts to run (for full & differential, or farm-level & content db’s
only), then you would schedule each script separately using this same method. In most
organizations, I recommend starting with weekly PowerShell full farm-level backups, and nightly
PowerShell backups of content databases. One advantage of scripting these backups via
Powershell is the ease of multi-threading. The Backup-SPFarm cmdlets includes a ‘–threads’
parameter, and by putting each content db backup in its own script you can schedule them
independently where each one starts with its own thread. That also allows you the flexibility to
backup some content databases more frequently than others.
That’s all you require to create useful, inclusive, and granular restore capability for your 2010
SharePoint farm. A big part of the reason this is so powerful though, is on the restore side of the
equation. Look for a follow-up post that describes in detail how to use Central Admin and / or
PowerShell to restore what you have painstakingly backed up.
In a previous post, I documented some of the exciting new functionality that PowerShell
provides for backing up a SharePoint 2010 farm. Now, let’s look at the other side of the coin –
restoring.
The way you would go about recovering from each of these scenarios would be very different.
In this post, I’ll address the first – Content Deletion. I’ll do a follow-up post to address the
admin-level mishaps and recovery from a true disaster.
For now, let’s pretend that some well-meaning power user has been trying to clean up the Logos
library in our root site to eliminate redundancy and recover some space within our quota.
However, they have inadvertently deleted the logo used as our site image – and in a quest to be
thorough they’ve deleted it from both Recycle Bins before they noticed the problem.
We can now use the Central Admin site to look for a content database backup that predates the
deletion, and then restore the content at as small of a scale as possible.
Go to Start > Administrative Tools > SharePoint 4.0 Central Administration, and then click the
Backup and Restore link on the left.
Select New configuration, and enter either a new directory name, database name, or server
name. Then click the Start Restore button.
The timer service will now schedule and immediately run a job that asks the back-end SQL
server to restore the old database without overwriting the live one. The time it takes will
obviously vary according to the size of the database and the concurrent activity on the SQL
server. The Job Status page will likely eventually show an error related to attaching the
database to the Web Application. That’s not a problem – we didn’t want the old database to be
Return to the Backup and Restore page via the left-hand navigation pane, and click the Recover
data from an unattached content database link in the bottom section.
Enter the Database Server and Database Name, choose to Export site or list, and then click
Next.
Go to Start > Administrative Tools > SharePoint 4.0 Management Console, and type the
following command:
Import-SPWeb –Identity http://yourportalURL –Path
filenameandpathtocmpfile –Updateversions 3
This one felt a bit disconcerting to me at first, but we have to understand how the cmp file and
the import command work. Notice the command is Import-SPWeb, not SPList. This is why it
In a short series of articles I’ve been documenting some exciting new disaster recovery
functionality included in SharePoint 2010. (As a side note, this may be the only Google search
that you could do that contains both ‘exciting’ and ‘disaster recovery’ in the same sentence…)
The way you would go about recovering from each of these scenarios would be very different.
In a previous post, I addressed the first – Content Deletion. Now let’s talk about the admin-level
mishaps and recovery from a true disaster.
Admin-Level Mishaps
There are many times we as admins make a change to a farm’s configuration that seems logical
at the time, but messes up something else in unanticipated ways. Sometimes these changes are
very large and / or complex and therefore difficult or impossible to put back manually. If you’ve
been performing scheduled full farm backups via PowerShell, or even just done a manual
backup beforehand in the Central Admin site, you can usually find a way to restore just the
affected pieces. Let’s pretend that our boss’s nephew who’s spending the summer as our IT
intern has messed up the configuration of our search content sources. (Of course WE wouldn’t
have messed it up…)
Click the Restore from a backup link in the top section, then pick the relevant full farm backup
from the list provided and click Next.
Select the Same configuration button to overwrite the existing, wrong configuration and
replace it with the known good configuration from the farm backup. This will cause one of
those ‘are you sure’ kinds of prompts. Just click OK and then click the Start Restore button.
That should do it. The job will take a few minutes to complete, but when it does, your content
sources will be restored to their previous condition.
This restore operation could also be done via PowerShell using the Restore-SPFarm cmdlets with
the –Item parameter. (See its topic in the online SharePoint 2010 PowerShell Reference forum
for more information.)
Whether it’s a natural disaster like a flood, hurricane, tornado, or earthquake or a man-made
one like a building fire or hardware failure – we must think ahead to the possibility of losing our
entire farm. The PowerShell full farm backups you’re running on a scheduled basis, and possibly
the PowerShell content database backups too, can rebuild all of your configuration and content.
Let’s think happy thoughts, and pretend that only the SAN holding our virtual server drives died
instead of picturing a wall of water through our town. What do we do now?
There are many external and / or third-party solutions used to protect entire servers. Let’s
assume in this example that we have none of that. We are starting with a blank Windows 2008
Server image and we need to get our portal operational as soon as possible. We are assuming
that we have the following at our disposal:
(IMPORTANT: Including the spbrtoc.xml. This is your backup history file, and without it
you are toast. Make sure you do not delete this file accidentally when reclaiming disk
space, and make sure your off-site backups include it from the root backup directory.
The spbr##### folders ARE NOT ENOUGH by themselves.)
Now what?
Reinstall SharePoint from the installation media, and run the initial SharePoint 4.0 Products and
Technologies Configuration Wizard to create a farm and configuration database.
The Central Admin site should open automatically and begin the web-based Farm Configuration
Wizard. (If not, you can find it by going to Start > Administrative Tools > SharePoint 4.0 Central
Administration, and choosing Configuration Wizards from the left-hand navigation.)
(Now this feels a little counter-intuitive to me, but it is a good idea to let this wizard start up all
of the relevant service applications before performing your restore. When I did not do this, I
received errors as the restores tried to configure the web and service applications from scratch.
If you opt not to run the wizard before the restore, you can do so after the restore completes to
catch any service applications that did not restore successfully. However, you may have to
restore and run the wizard multiple times to get everything to finish.)
Choose an existing managed account or enter one in the blanks provided, select all service
checkboxes, and click Next.
(If you are restoring a multiple-server farm, you would need to perform steps 1-3 on each server
– starting only the relevant service applications on each server in turn.)
When the ‘Processing…’ page completes, the wizard will give you the option to create a new site
collection. Click the Skip button and then the Finish button.
Now you are prepped for the farm restore. You could do this using a process very similar to the
one documented and illustrated in section ‘2. Admin-Level Mishaps’ above. The only difference
would be selecting all components in the tree instead of one. For a little variety though, we’ll do
this restore using Windows PowerShell instead.
Go to Start > Administrative Tools > SharePoint 4.0 Management Console, and type the
following command:
(For a complete explanation of the Restore-SPFarm cmdlet, its parameters, and its usage, see its
topic in the online SharePoint 2010 PowerShell Reference forum.)
The SMC window will prompt you to verify the action and the overwrite, and eventually to enter
credentials for your user web applications.
That should restore all relevant content and configuration to your SharePoint 2010 farm. Like
most disaster recovery situations – your mileage may vary according to the complexity of your
environment, the integrity of your backup data, and a million other wrinkles you couldn’t have
seen coming. If the SMC window gives you an error message, the sprestore.log file in your
backup directory will give you more detailed information about the problem encountered. In
my own trial runs with this functionality, I did receive an error now and then. Usually they had
to do with a file or some other dependency not being available. In some cases simply running
the restore-spfarm cmdlets again was successful the second time. In other cases I had to start
the problem service application through the Central Admin site and its web-based Farm
Configuration Wizard, and then run the restore again to inherit my previous configuration.
Introduction
As a SharePoint developer, mirroring the style of the SharePoint user interface in a custom
application is important to create a homogeneous experience for your end users. One of the
best opportunities to accomplish this is by creating a custom ribbon tab containing
contextualized buttons to suit your application.
In this article I’ll show you how to define a new SharePoint Ribbon Tab which includes a button
group and a collection of ribbon buttons like Laugh and Giggle. I’ll discuss how to extend the
CUI.Page.PageComponent JavaScript object to quickly configure ribbon button command
actions. Finally I’ll discuss how to make your custom ribbon tab available from a Layouts page.
We begin by deploying a custom ribbon tab definition to your SharePoint environment. This is
done using the <CustomAction /> element of a SharePoint feature. We begin by defining a
<CustomAction /> element with the location of ‘CommandUI.Ribbon.Tabs._children’. This will
add our custom ribbon tab defined in the <CommandUIDefinition /> element to the collection of
available SharePoint ribbon tabs.
A SharePoint ribbon tab is comprised of HTML and JavaScript elements. Buttons residing on the
ribbon tab are coordinated using JavaScript methods. By following the template used on many
of the SharePoint pages we can easily set up the necessary JavaScript methods to orchestrate
our ribbon events.
The first step is to create a JavaScript object containing the appropriate JavaScript methods to
coordinate the ribbon tab buttons. We start by creating a file named RibbonApp.UI.js and
provide an object definition for our custom ribbon page component named
‘RibbonApp.UI.RibbonAppPageComponent’. This JavaScript object derives from
‘CUI.Page.PageComponent’ and provides the necessary methods to coordinate the ribbon tab
buttons.
The most important methods of the RibbonAppPageComponent can be found in the prototype
definition. Inspecting the methods below you will notice calls to global JavaScript functions
getGlobalCommands, commandEnabled and handleCommand.
Once the ribbon tab is defined and the page component created it is time to add the ribbon to
your SharePoint .ASPX page. We start by creating a private method named InitializeRibbon
which gets called from the Page_Load method of our SharePoint page. We begin the method by
getting a reference to the current SPRibbon element and check to ensure the current ribbon is
not NULL.
Once we have a reference to the current ribbon we can begin defining the ribbon behavior. We
start by setting some basic ribbon properties and adding the available tabs. The Id passed to the
MakeTabAvailable method must match the value defined in our ribbon tab definition. We can
The ribbon uses the ‘SP.js’ and ‘SP.Runtime.js’ JavaScripts. To ensure these scripts are registered
on our page we make two calls to the RegisterScriptAfterUI method. We would also like to
register our RibbonAppPageComponent. The SPRibbonScriptManager contains a method to
register this script and call the initialize method after the page is loaded. Unfortunately access to
this method is private. To correct this deficiency we created our own RibbonScriptManager class
to register and initialize the RibbonAppPageComponent.
Finally we need to wire up our ribbon buttons to perform meaningful operations. This is
accomplished by creating a list of IRibbonCommands. The simplest ribbon command can be
created with the ribbon command name, JavaScript action command and JavaScript enabled
command. In the code below we are going to register the Laugh button which has a hardcoded
enabled value of ‘true’. When the button is clicked we send an alert to the user.
The enable JavaScript string could easily be turned into a JavaScript method which might inspect
the page state to determine button availability. This can be seen in the JSEnableDisable button
which defines the enabled script to IsJSEnabled(). The IsJSEnabled() method corresponds to a
JavaScript method placed on the page to determine the button state. If a Boolean value of true
is returned from the method the JSEnableDisable button will be clickable. If a Boolean value of
false is returned the JSEnableDisable button will be disabled.
Your ribbon tab is now ready. Build and deploy your application to your SharePoint environment
and enjoy the fruits of your labor. If you make a lot of changes to your ribbon you will notice IE
caches a lot of ribbon content. It may be necessary to delete your cached files after an update or
turn off caching all together.
The SPRibbonCommand is used to interact with page components via JavaScript. Other
SPRibbonCommands can be used to provide alternate types of interactions. Other ribbon
command types available are the SPRibbonPostBackCommand, , SPRibbonQueryCommand and
the SPRibbonPopulateQueryCommand. .NET programmers are accustomed to creating buttons
which post back to a code behind page where additional programming actions can be taken. To
do this we leverage the SPRibbonPostBackCommand.
Conclusion
The ribbon is new to SharePoint 2010 and is being embraced by Microsoft. The ribbon is making
its way into many Microsoft applications like the Office Suite, WordPad, Paint and Windows 7.
Consumers of Microsoft products, including SharePoint users, will come to expect a ribbon
driven menu to be included in custom applications.
Creating a custom ribbon tab for your SharePoint application doesn’t have to be a pain and can
be accomplished by defining a ribbon tab definition, creating a PageComponent to coordinate
ribbon events, and initializing the ribbon in your application page. Using a custom ribbon tab is
an excellent way to present custom actions in your application while maintaining a cohesive
visual experience for your users. Wow your users by including a custom ribbon tab in your next
SharePoint application.
Introduction
One of SharePoint’s neatest features is the People Picker. It allows a SharePoint user to
elegantly query, identify, and select SharePoint accounts. Did you know the People Picker is built
on a set of publically available picker controls available to every SharePoint developer? Read the
rest of this article to find out how to include a custom picker into your new SharePoint
application.
Cast of Characters
Developing a custom SharePoint picker involves the creation and orchestration of three
components, the Editor, Picker Dialog, and the Query.
Editor
The editor provides an entry point for the user to express the selected entities. It also provides a
launch pad to open a popup picker dialog box and search for entities. The editor class derives
from Microsoft.SharePoint.WebControls.EntityEditorWithPicker.
The picker dialog is a popup window which appears when the SharePoint user wants to search
for one or more entities. This dialog box can be opened by clicking the editor’s browse button.
By default the picker dialog is setup to take a search expression and display the matches in the
results panel.
Query
The Query control provides the visual results component of the picker dialog. This is the class
responsible for accepting the search criteria, obtaining a list of matching entries, and creating
the table of matching entries to be displayed inside the picker dialog. The query class derives
from Microsoft.SharePoint.WebControls.PickerQueryControlBase.
Before any of the picker components can be developed we need to identify an entity object to
represent the selected data. A simple city entity can be represented with the following model.
Once an entity is defined the editor, picker dialog and query controls can be created. Each picker
control has references to the other two controls which creates a dependency between each
control. As a result, creating the three controls before defining the control body simplifies the
process. We begin by creating a class named CityEditor which derives from
Microsoft.SharePoint.WebControls.EntityEditorWithPicker. Second, we create a class named
CityPickerDialog which derives from Microsoft.SharePoint.WebControls.PickerDialog. Finally, we
create a class named CityQueryControl which derives from
Microsoft.SharePoint.WebControls.PickerQueryControlBase. The three city picker controls have
the following properties and methods.
The editor provides an entry point for the user to express the selected entities. The main job of
the Editor is to validate entities provided by the user and provide a launching pad to open a
picker dialog box to search for entities. We start by setting up the picker dialog by setting the
PickerDialogType property to the type of our CityPickerDialog class. This informs SharePoint to
use the CityPickerDialog control when searching for new cities.
We then want to define how entities are validated by our city picker. We do this by overriding
the ValidateEntity method. In this method we inspect each city provided by the user. If the city
is not already resolved we look for a matching city in the AllCities property of the CityManager
class. If a valid city is found we mark the city resolved. If not city is found we return the city in
the current unresolved state.
Picker Dialog
The picker dialog control is the simplest picker class to create. It is used to set up the dialog
window properties and the column properties used by the search results. We start by defining
the results control used to display the matching cities.
Using the OnLoad method we set up the title and description of the dialog window.
Query
The query control is used to issue queries and return the results to the picker dialog. The
CreateDataTable method is used to create a System.Data.DataTable from the columns defined
by the picker dialog control. The GetEntity method is used to convert a DataRow to a
PickerEntity when an item is selected. The interesting work performed by the query control
occurs in the IssueQuery method.
The IssueQuery method takes the search parameters and obtains the search results. The
CreateDataTable method is called to build a DataTable used to pass our data from the query
control to the picker dialog. Once the DataTable is filled with the results of the search the results
are passed to the picker dialog using the PickerDialog.Results property. Finally the number of
matching records is returned to enable paging if necessary.
Once the editor, picker dialog, and query picker controls are in place we can add it to a
SharePoint page in the same manner as any other control. The first order of business is to add a
<SafeControl /> entry for our assembly to the web.config file and register the control
namespace at the top of our .ASPX page. We can then add the editor control.
The final step is to obtain a list of resolved entities when a page action occurs. To get a list of
resolved entities simply call the ResolvedEntities property of the CityEditor instance.
Conclusion
Introduction
With each new release of SharePoint, Microsoft has managed to further improve this platform’s
programmability, extensibility, and manageability. Among many other exciting new features
and capabilities, the new 2010 release of SharePoint now provides developers with ASP.NET
AJAX as a first-class tool in our proverbial toolbox. AJAX has been around for some time now,
and it is great to finally see both native and custom SharePoint applications will be enabled with
the same rich, interactive user controls we’ve come to expect from quality browser-based
applications. Yet another exciting technology that ships with SharePoint 2010 is the Service
Application Framework. The Service Application Framework allows developers to create robust
and scalable shared services which can be consumed by multiple SharePoint web applications.
In this article, I’ll show you how to create and provision a SharePoint Service Application. Within
the service application I’ll define a WCF service endpoint which provides auto-completion
services to ASP.NET AJAX-enabled controls. Finally I’ll leverage this WCF service and the
ASP.NET AJAX Toolkit to provide users with a simple Geo-locator page. The Geo-locator will
prompt a user for a city and state, suggesting known values in real-time as the form’s fields are
completed. Once a city and state have been keyed, the user will be shown the specified location
on a satellite map.
Admittedly, the use case set forth in this demonstration in somewhat contrived. Using
SharePoint’s Service Application Framework to simply provide AJAX controls with auto-
completion services is really beating a small nail with a big hammer. In most real-world
production scenarios, such trivial functionality could probably be achieved with a simpler site-
level web service. I’ve chosen such a simple use case so as to not distract from the primary
purpose of the article, which is to illustrate how to create and provision the skeleton of a simple
SharePoint Service Application.
The topic of SharePoint Service Applications is broad and technically advanced. Areas such as
scalability, fault-tolerance, external service publishing, security, database provisioning and data
backup are left for another demonstration. That being said, in this article I will get you started
by showing the basics of creating, provisioning and hooking into the Central Administration
management interface for SharePoint Service Applications.
To follow along with this demonstration, I assume you have the following requirements installed
and functioning properly.
Required
Optional
SPService
A service provides a very narrow range of functionality that usually does not include end-to-end
functions that are valuable in themselves. Services typically run invisibly and have little or no UI.
Every SPService object has an Instances property that holds all the instances of the service that
are running on various servers in the farm. No more than one instance of each service runs on
any one server, but some services have multiple instances, each one running on a different
server. Each instance is represented by an object of a class derived from SPServiceInstance.
SPServiceInstance
SPServiceApplication
A service application is hosted by a service instance. Service applications are generally created
by administrators. They provide the service interface, containing the administrator settings.
Service applications may own user data.
SPServiceProxy
SPServiceApplicationProxy
Service application proxies provide the public (front-end) interface to a service application. They
allow client code to consume remote service applications. Service applications may not be
installed locally and therefore cannot be called directly.
1. In Visual Studio 2010 I start out by creating a new Empty SharePoint project.
2. When prompted by the SharePoint Customization Wizard, I’m going to target the
Central Administration web, as this is where the service application will be deployed.
3. Next, I add a new class to the project and name it AutoCompletionService.cs. As with all
code artifacts in this demonstration, I’ll cover the highlights of this class, but refer to the
accompanying Visual Studio 2010 sample project for the complete listing. The
AutoCompletionService class inherits the SPIisWebService class and implements the
IServiceAdministration interface. Because this class is a persisted object, it must also be
decorated with the System.Runtime.InteropServices.Guid attribute and assigned a
unique guid.
5. I’ll add three more classes to the project. I’m going to name the new classes
AutoCompletionServiceProxy.cs, AutoCompletionServiceApplication.cs and
AutoCompletionServiceApplicationProxy.cs respectively.
11. In SharePoint 2010, WCF web services are stored at the path [14 Hive]\WebServices. On
most systems the full path to this location is C:\Program Files\Common Files\Microsoft
Shared\Web Server Extensions\14\WebServices. In Visual Studio 2010, I’ll create a
SharePoint Mapped Folder to this location by right-clicking on the AutocompleteDemo
project in Solution Explorer and selecting Add > SharePoint Mapped Folder. Note the 14
hive’s WebServices folder at the bottom of the list.
12. Next, I’m going to expand the newly created WebServices mapped folder and right-click
on the AutocompleteDemo folder below. From the context menu, I select Add > New
Item. In the Add New Item dialog, I select the WCF Service template and name the new
13. I’m going to move the App.config file that was added automatically to be in the same
folder as YouCompleteMeService.cs. Then I rename App.config to web.config and
delete its contents. I’m going to create my own configuration file. In the web.config file
I’ll turn on aspNetCompatibilityEnabled, define a default endpoint for our WCF service,
and also turn on enableWebScript for AJAX compatibility. Refer to the accompanying
14. For some reason, Visual Studio 2010 doesn’t automatically add a WCF Service Host
declaration file to the SharePoint Project for me. At least in the VS2010 Beta, I’ll have to
add this file manually. To do so, I just add another file to the AutocompleteDemo folder
below WebServices mapped folder in the project. I select a Text file as the file type and
name it YouCompleteMeService.svc. This Service Host file will only contain a few lines
declaring the service and its factory.
18. Next, I expand the Features folder of the AutocompleteDemo Visual Studio project and
right-click on Feature1. From the context menu, I click Add Event Receiver. In the newly
created Feature1.EventReceiver.cs class, only the FeatureActivated method is salient to
this application. In the FeatureActivated method, I check to see if an
AutoCompletionService object has ever been created, and if not create it. Only one
local AutoCompletionService will ever be needed. After an AutoCompletionService has
1. In the project, I’ll add a SharePoint Mapped Folder to the *14 Hive+\TEMPLATE\ADMIN
directory.
2. In Solution Explorer, I’m going to expand the newly created ADMIN mapped folder,
right-click the AutocompletionDemo subfolder, and from the context menu Add > New
Item. I select a SharePoint Application Page and name it ServiceCreate.aspx. Then, I
3. The ServiceCreate page will be a popup dialog box, and as such should be modified to
inherit from SharePoint’s ~/_layouts/dialog.master master page. This page will
implement place holders for its master page’s PlaceHolderDialogHeaderPageTitle ,
PlaceHolderDialogDescription and PlaceHolderDialogBodyMainSection content
6. The ServiceManage page is where developer’s are free to add any user configurable
settings for the service application. The Auto Completion service application has no
user configurable options, so this page is largely left blank for the purposes of our demo.
Note that this page’s master page is ~/_admin/admin.master.
7. At this point, the Auto Completion service application can actually be deployed to
SharePoint, and instances of the service application can be provisioned in Central
Administration. Of course, the application doesn’t actually do anything yet, but the core
infrastructure pieces have been defined. To verify this, right-click on the
AutocompleteDemo project in Solution Explorer and select Deploy. The solution will
deployed, and after a few seconds, you should see a “Deploy succeeded” message in the
8. To verify deployment, I can open SharePoint’s Central Administration site and click on
Manage service applications under the Application Management menu heading.
9. Selecting any item in the list of services will cause the Service Applications ribbon to
appear. I’ll click the New button to see the Auto Complete Service Application list
11. Congratulations! If everything works on this next step, most of the hard part is over. I
can go ahead and complete the form by entering an instance name and selecting an
application identity. When finished, I click OK to provision the service application. If the
provisioning succeeded, a pair of listings for the new service application and its proxy
should now be available on the Manage Service Applications Page. I haven’t added any
user configuration options for this demonstration, but clicking the listing’s link to will
12. One more step to verify the provisioning was successful is to check that the service
application’s virtual application was created in IIS. To do so, I can open Internet
Information Services (IIS) Manager from Administration Tools on the Start menu of the
Windows Server running SharePoint 2010. Next, I’ll expand the Sites node and then
expand the SharePoint Web Services node below that. I right click on one of the virtual
13. I’m looking through the list of virtual applications which have guids for names. Notice
SharePoint’s built-in service applications such as MetadataWebService.svc and
WebAnalyticsService.svc. I’m looking for the virtual application with a guid for a name
that that contains our Service Host file YouCompleteMeService.svc. If everything checks
out, the empty WCF service has been provisioned.
3. Note that I’ve created a helper class to handle supplying data to the service methods.
The actual data resides in a simple, albeit lengthy text file. CitiesHelper reads said data
and performs simple Linq queries to filter on the correct city and state names.
CitiesHelper uses a singleton pattern to avoid excessive file I/O and memory usage. In a
real-world production scenario, a more robust SQL database to house this data could
have been provisioned along with the Service Application. However, for the purposes of
this demonstration a simple text file will do fine. Refer to the accompanying project for
1. The ASP.NET AJAX Control Toolkit is an open-source project built on top of the Microsoft
ASP.NET AJAX framework. It is a joint effort between Microsoft and the ASP.NET AJAX
community that provides a powerful infrastructure to write reusable, customizable and
extensible ASP.NET AJAX extenders and controls, as well as a rich array of controls that
can be used out of the box to create an interactive Web experience. I’m going to use
the toolkit’s AutoCompleteExtender to transform a plain old SharePoint
InputFormTextBox into an AJAX enabled overnight sensation!
a. I’ll create a folder called Dependencies in the same directory as the Visual
Studio solution file. I’ll need to download the ASP.NET AJAX Control Toolkit
binaries from this URL and add the AjaxControlToolkit.dll to the Dependencies
folder.
b. http://www.asp.net/ajax/downloads/
2. In Visual Studio, I’m going to add a new SharePoint Empty Project to the solution and
name it AutoCompletionDemoTest. This time, I’m sure to target a regular SharePoint
content application (not Central Admin as before) from the SharePoint Customization
9. In code-behind file Test.aspx.cs is where I’m going to add control extenders for the
page’s two text input controls. These extenders will handle communicate with the WCF
service’s GetStates and GetCitiesForState web methods to provide suggested auto-
10. To tie everything together, I’ll also add a GetServicesEndpointPath helper method the
test page’s code-behind. This method will go through the Auto Completion Service
Application’s proxy to determine the default service endpoint.
1. From Visual Studio, I’m going to re-deploy the AutocompleteDemo service application
project to Central Admin to ensure the WCF endpoint’s logic is in place.
application.
3. To see the end result, I can browse to Test.aspx in my SharePoint Content Application
by visiting the URL:
a. http://[myserver]/_LAYOUTS/AutoCompletionDemoTest/test.aspx