SharePoint Designer 2010 Workflows Preview PDF
SharePoint Designer 2010 Workflows Preview PDF
Issue
SharePoint Designer
2010 Workflows
USPJA Publishing
USPJA Publishing LLC
831 Beacon Street
Suite 118
Newton Centre, MA 02459
United States
Phone +1 877 90 USPJA
http://www.understandingsharepoint.com/journal
[email protected]
Credits
About the Author
Bjrn Christoffer Thorsmhlum Furuknap is a senior solutions architect,
published author of Building the SharePoint User Experience, speaker, and
passionate SharePointaholic. He has been doing software development
professionally since 1993 for small companies as well as multinational
corporations. He has also been a teacher at a college-level school, teaching
programming and development to aspiring students, a job that inspired him to
begin teaching what he has learned and learns every day.
Other Credits
A great big thanks to Kim Wimpsett for doing the copyedit. The quality of work in this issue is greatly
attributed to her skill. Jon Tobey has also been an invaluable help in writing this issue.
Table of Contents
Credits....................................................................................... i
About the Author .............................................................................. i
About Understanding SharePoint Journal ........................................ i
Other Credits.................................................................................... i
Setting Activities...................................................................................... 32
Publish the Workflow .............................................................................. 37
Introduction
Asking the right question at the right time to the right people can trigger a landslide.
Welcome to the wonderful world of SharePoint Designer workflow. Through this
issue, youll learn much of what you need to become productive as a workflow
developer using Microsofts latest version of SharePoint Designer.
If you are a new reader of USP Journal, then a second welcome is in order. For
previous readers, however, you may notice some changes to this issue, and Id like to
point them out before we go on to the learning. First, this issue has taken a long time
to write. The reason is that in the past few months, I have been very busy starting the
worlds first SharePoint university, called USPJ Academy. Were still in the Early
Access period where only a select few students have been enrolled to help us evaluate
the platform and content, but there is still so much work to do that finding time to sit
down and write is difficult.
Second, for this issue, I have elicited some outside help in the writing. Jon Tobey
generously offered to help out to speed things up and has provided invaluable advice
and content for this issue.
Third, the entire USP Journal is now part of USPJA Publishing, the publishing arm of
USPJ Academy. That wont necessarily affect the journal directly beyond the address
change on the second page, but it does mean that the future of the journal is looking
brighter than ever.
I hope you enjoy this issue and that youll get everything you need from it. As always,
I value your feedback, so please send that to [email protected] if
you have any questions, comments, or suggestions.
.b
Chapter
Workflow in a Nutshell
Understanding the path you walk
Welcome to one of the most powerful features of SharePoint: workflows. Inside
that small word lies a world of opportunity and perhaps the single most valuable
piece of technology currently available. Workflows bear the promise of business
process optimization beyond the wildest dreams of anyone.
I C O N
K E Y
Valuable information
Exercise
Caution
OK, Ill stop the marketing talk. Were not here to blindly buy into what Microsoft
says; we are here to understand SharePoint and increase our knowledge of
workflows in SharePoint Designer. By virtue of that alone, we will become all the
marketing SharePoint requires by showing how great this tool and platform can be.
Before we can commence any investigation into SharePoint Designer, we need to
understand some key concepts in workflows.
Workflows saw a rise in popularity after Microsoft started marketing Windows
Workflow Foundation as part of the .NET Framework. Released as part of .NET 3.0
in 2006, workflows quickly became an important part of business applications even
for smaller businesses and projects. These days, it seems you cant walk down the
street without stepping into one or more workflows.
Note
Retrieve the item, and run before the attendant notices the missing pen.
Dont be fooled. This task may seem simple, but thats only because we do it so
often it has become routine. Several of these steps require a number of substeps, and
any failure will need to be handled according to some set of rules.
A workflow structures such processes into manageable chunks called activities.
Each activity performs one or more small operations, such as verifying an amount
or stealing a pen, and the workflow makes sure that everything is done in order and
handles exceptions to the regular flow.
State machine workflows can cope with this situation much better than sequential
workflows because state machines by design encourage jumping between different
states depending on the outcome of other states.
Note
This issue of the journal will deal only with sequential workflows,
because SharePoint Designer sadly supports only sequential
workflows.
That said, you can simulate a state machine workflow in SharePoint
Designer by using a repeating workflow and what are known as
secondary workflows. Explaining the details of how to do this is
beyond the scope of this issue, and frankly, theyre not recommended
in a production environment.
Note
Workflow Terminology
If you are new to workflows, the terminology can be confusing at best. To help with
this confusion, I have compiled the following sections, which explain the various
terms and phrases that comprise the workflow lingo.
Actions
Actions are the individual tasks that a workflow performs during its execution. An
action can be sending an email, assigning a task to someone, creating a new list
item, or performing many other tasks.
Actions or Activities?
The terms actions and activities refer to the same thingthe individual
tasks performed in a workflow. Throughout this issue, I am using the
term action, but you may encounter the term activity in other
situations.
We will examine many of the available actions throughout this issue.
Branches
A branch in a SharePoint Designer workflow is an action or set of actions that the
workflow performs if a condition is met. A branch can also have no conditions and
is then called a default branch.
The default branch will execute if none of the conditions on other branches is met or
if there are no branches with conditions at all.
If multiple conditions are met, the branch defined first in the step will execute.
10
Mission Statement
Throughout this journal, we will learn about SharePoint Designer workflows. We
will do so by creating a solution that mimics the grade process at the USPJ
Academy.
11
SharePoint Designer:
First, you need an up-to-date SharePoint installation. You should make sure you get
the most recent updates as well, because fixes and updates may alter your
experience.
http://www.microsoft.com/spd
SharePoint Foundation
2010:
http://www.understandingsharepoi
nt.com/url/10103
Second, you will of course need SharePoint Designer (SPD). SharePoint Designer
was released free of charge on April 2, 2009, so all you need to do now is download
and install it. You will find the link to SharePoint Designer 2010 in the sidebar to
the left.
Note
We will use only supportable methods and not harm a single Microsoftprovided file.
If you modify any file that ships with SharePoint, you will not be able to get
support for your solution from Microsoft.
12
13
Chapter
SharePoint Designer
Overview
Might as well get going, eh?
Now that we have a good understanding of what a workflow is, we can move on to
exploring how a workflow is implemented in SharePoint Designer.
In this chapter, Ill give you a brief overview of what SharePoint Designer
workflows are, and Ill also introduce you to the SharePoint Designer interface so
you know where to find all the buttons and options you need.
Perhaps a good starting point is to explain what SPD workflows are not:
Although you can create new activities to use in SharePoint Designer, this
requires programming skills or the addition of third-party tools.
In previous versions of both SharePoint and SharePoint Designer 2007, this list
included the fact that SharePoint Designer workflows were not reusable. In practice,
this meant that you could not move your workflow from a development
environment to a production environment.
However, this has now changed. Not only can you reuse your workflow in multiple
sites and farms, but you can even export your workflow into other tools for further
refinement.
14
None of this may mean much to you, but Ill explain everything throughout this
issue.
Lets see what SharePoint Designer workflows are all about.
15
List Workflows
A list workflow in SPD 2010 is the same type of workflow that was available in
SPD 2007.
A list workflow is forever tied to a single list and cannot be reused later. Once
youve attached a workflow to a list, theres no supported way to change that list
affiliation. However, you can still change the workflow process.
This also applies to the same list in a different site. You cannot export the workflow
from one site to another site, effectively killing the reuse of list workflows. Another
consequence of this is that you have to create all your production workflows in your
production environment.
This may or may not pose a problem for you. If what you want is a quick way for
business users to solve a problem, designing your workflow in your production
environment may be just the right thing, although it has implications for testing
mission-critical workflows.
Reusable Workflows
The reusable workflow addresses the problem of list affiliation. This type of
workflow, introduced in SharePoint 2010, solves list affiliation by simply not being
tied to a list at all.
This seems at least initially like a great solution, and it does offer some more really
useful options for workflow creation.
However, SharePoint Designer workflows are declarative in nature. That means
you declare, during design, what the workflow should do. The problem is that,
because the workflow has no idea on what kind of list it will run in, it also cannot
use any of the columns in any of those lists.
A-ha! thought the SharePoint Designer development team. Well make the
workflow affiliate with a content type instead! This is a brilliant idea that allows
you to connect a workflow to a type of content rather than where that content is
stored.
The brilliance of this approach becomes apparent when your site has structured
content and you utilize content types for your taxonomy.
Well cover reusable workflows in the solution in Chapter 8.
16
Site Workflows
The final type of workflow you can create in SharePoint Designer 2010 is a site
workflow. Again, this is a very good idea that may seem utterly useless at first. I
mean, why would you want to run workflow on something other than list items and
documents? After all, isnt the whole purpose of a workflow to have some sort of
data that behaves in a certain manner?
Well, you may be right, but there are many situations in which you dont want to
work directly with a specific piece of data. For example, if you dont have that data
yet but require someone to upload or add that data, youd want to run a workflow
outside the context of a specific item or list.
In this journal issue, well do just that, and well create a new grade report requested
by someone. That grade report will be a Word document that doesnt exist when the
workflow starts.
Well also cover site workflows in the solution in Chapter 8.
Note
17
SPD 2010 comes in two flavors, a 32-bit edition and a 64-bit edition. You may be
tempted to get the 64-bit edition because, well, higher is better, right? Before you
do, consider the following.
If you plan on using both SPD 2007 and SPD 2010 on the same machine, you need
the same edition of both software packages. Because SharePoint Designer 2007 is
available only in 32-bit edition, that means you must have the 32-bit edition of SPD
2010 as well.
Also, your SharePoint Designer 2010 flavor must match the Office version you
have installed, if you have one. Thus, if you have a 32-bit Office edition installed,
you also need the 32-bit edition of SPD 2010.
Regardless which version you choose, install it by following the installation guide
that comes with the package (its really easy; even Spouse mode doesnt apply
here), and fire up the program once it is installed.
Backstage UI
If youve worked with SharePoint Designer 2007, you will see that this is actually a
vastly different interface than you are used to using. One of the things you will
notice is the backstage view that the Office 2010 suite of applications has
implemented to replace the Office Button from Office 2007, as you can see in
Figure 1.You will also notice the Ribbon, which is new for Designer 2010.
18
You will also see some options that are unique to SharePoint Designer 2010. Most
of this is for creating new lists, pages, and workflows, which is what were
interested in. You can also see the various sites, and you will have access to all the
options you had in SPD 2007.
Right now, though, just reopen the tab that holds the site to which we connected. In
Figure 2, notice that you now have the Ribbon, which creates what Microsoft calls a
fluid interface. In other words, whatever task youre doing, the available options in
the Ribbon will change. You have icons to make it easy to see whats going on. It
might take a bit of time to get used to if youve never worked with the Ribbon, but
its a nice improvement if you ask me.
19
If you have worked with SharePoint Designer 2007, you know that its
wizard was actually a pop-up modal dialog box that ran on top of the
rest of SharePoint Designer. In 2010, the entire SharePoint Workflow
Designer is integrated into the same interface that you use for
everything else.
Also note that the various tabs have a breadcrumb underneath. It works like a lot of
other breadcrumbs, but you can also click the sidebar, side or right arrows, buttons,
or whatever you want to call them to get quick access to all the other stuff available
here. Another new thing is that you can actually have multiple workflows open at
the same time.
20
When you add a new workflow, you enter directly into the editor for the workflow,
but theres a profile page, or a settings page, for the workflow where we change all
the settings for this workflow. You can access the settings page by clicking the
name of the workflow in the breadcrumb. We can change the names and description
here, as well as investigate or configure the task and history lists, change start
options, and manage forms.
Note that the settings page looks slightly different between the various types of
workflows, mainly in the start options.
You have the common settings that youre used to if youve ever worked with
SharePoint Designer workflows, and if not, youll see what all of this means as we
go along.
Task and History Lists
All workflows have a task list, which is where you store the tasks you create for
users. Well be doing that a lot in the workflow that well be building throughout
this issue. This list is just a normal SharePoint task list, and this knowledge allows
you to control where you want tasks to appear for your workflows.
You can, for example, create multiple task lists, and you can have different task lists
for each of the various workflows that youre creating. You can have one task list
that is specific to one workflow; you can group them, for example, to put HR tasks
in a separate task list; or you can do any kind of combination that you actually want.
The same thing applies to the History List, which is where you log all the stuff
thats going on whenever a workflow changes state for debugging or approval.
Again, you can select that per workflow, you can have one list for all your
workflows (which is the default), or you can group them.
Well go into details on what these lists actually do and how you work with them
when we look at collecting data from users in Chapter 6. There are some quirks
there of which you should be aware, but Ill brief you on them when we get to the
details later in this issue.
The Start options are on the right side. These options change slightly between the
various types of workflow. There are two major categories here: an item-based
workflow, which are the Reusable and List workflows, or the Site workflows,
which are not based on any list or content types.
You can start site workflows either manually or automatically as part of some other
process. If youre using the item-based workflows, however, you have more
options. You can start the item automatically whenever a new item is created or is
changed; you can, as for the Site workflow, start it manually if you want; and you
can combine them in whatever way you like.
21
All workflows have various forms used for initiating workflow, getting data from
users, modifying the workflow, and so on. These forms are basically just plain
ASP.NET pages.
That may scare you because ASP.NET is programming thing, and you dont want
to be a programmer, right? You dont need to worry about any of that, though,
because, by default, SharePoint Designer will create all these forms for you.
You will just say I want to initiate this workflow, and SharePoint Designer will
create an initiation form for you. The same things happen when you create activities
for collecting data; SharePoint Designer will build a form where users will enter the
data, and you dont need to know a word of ASP.NET.
Simple, eh?
Workflow Editing
When you want to edit a workflow, click the Edit Workflow link on the settings
page (its located in the Customization section). This will launch the Workflow
Designer canvas and give you a single step from which you will build your
workflow empire. You will also see a blinking yellow-orange cursor bar that
indicates where SharePoint Designer will add actions and steps as you build.
You can rename the steps if you want, which makes sense because when the steps
are called Step 1, Step 2, and so on, there is no context to tell you whats going on.
To rename them, simply click the title, type whatever you want, and then hit Enter.
That has nothing to do with how the workflow actually runs. Its simply so you
recognize the steps by name. In Figure 4, Ive renamed a step to Initiation Step.
22