Creating Workflows for Windows SharePoint Services Table of Contents Creating Workflows for Windows SharePoint Services ........................................................... 1 Exercise 1 Building a Workflow with Office SharePoint Designer 2007...................................................................... 2 Exercise 2 Building a Custom Workflow with Visual Studio ...................................................................................... 8 Conclusion ................................................................................................................................................................... 16
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Creating Workflows for Windows SharePoint Services
Table of Contents
Creating Workflows for Windows SharePoint Services ........................................................... 1
Exercise 1 Building a Workflow with Office SharePoint Designer 2007......................................................................2
Exercise 2 Building a Custom Workflow with Visual Studio ......................................................................................8
Creating Workflows for Windows SharePoint Services
Page 1 of 16
Creating Workflows for Windows SharePoint Services
Objectives After completing this lab, you will be better able to:
� Build a Workflow with Office SharePoint Designer 2007.
� Build a Custom Workflow with Visual Studio.
� Seamlessly integrate workflow functionality with the 2007 Microsoft® Office System release.
Estimated Time to Complete This Lab
90 Minutes
Computer used in this Lab
MOSS
Creating Workflows for Windows SharePoint Services
Page 2 of 16
Exercise 1 Building a Workflow with Office SharePoint Designer 2007
Scenario The city of Anytown, MI, needs an electronic process for building permit applications submitted by residents and business owners. This process requires that users be able to access a building permit application Office InfoPath 2007 form from the browser. After providing specific data about the project in the form, the user submits the data to an internal SharePoint form library, where it is assigned to a compliance reviewer for approval. The compliance reviewer uses the same form as a rich client to determine if the project meets certain requirements (for example, fire safety regulations) before submitting the form back to the form library. If all requirements have been met, an e-mail message is sent to the applicant indicating that the application has been approved and that the permit amount is due.
In this exercise, you will use Office SharePoint Designer 2007 to build this workflow process. Office SharePoint Designer 2007 enables site administrators to write workflow logic against any SharePoint list. Within the Workflow Designer users can specify action sets, which contain conditions and actions, without having to write any custom code. These action sets work with any form fields that have been promoted as SharePoint columns.
Tasks Detailed Steps
Complete the following
6 tasks on:
MOSS
1. Become familiar
with the Views task
pane
Note: Before working with Office SharePoint Designer 2007, it would be beneficial
for you to become familiar with the building permit application form template, which
has already been deployed to a SharePoint form library. This template is meant for
two types of users: (1) residents and business owners, and (2) compliance reviewers.
The residents and business owners (the applicants) provide building project
information, including the building size, lot size, property tax, project size, and project
cost. These values are used to calculate a permit amount. In addition, the Anytown,
MI, employee who will be assigned to review the application is determined based on
the selection of project type (for example, building extension). After the applicant
submits the form data to a SharePoint form library, the assigned compliance reviewer
then completes the compliance section, which will determine if the permit is approved
or rejected.
There is a form view for each type of user, with two form views for the applicant. The
View 1 (default) view is the one that is shown when the applicant first fills out the
form. The Initiator Rejected view is shown to the applicant if any of the compliance
requirements are not met, and allows that user to see comments from the reviewer.
a. Login using the following credentials:
• Username: administrator
• Password: pass@word1
• Log on to: LITWAREINC
b. Wait for the Warmup Script to complete and the popup window to close.
c. From Windows Explorer, navigate to C:\HOL\CreatingWorkflows\Exercise1.
d. Right-click BuildingPermitApplication.xsn and select the Design menu
command.
e. In the Design Tasks task pane, click Views.
f. In the Views task pane, click each form view to become familiar with the different
UI sections of the form.
2. View the Form’s
Data Source screen Note: You will need to be familiar with the form’s data source in order to write the
workflow logic. Some of the top-level nodes that are worth noting are the RoleID,
PermitStatus and PermitAmount. The RoleID node identifies the current user viewing
the form, with values of 1 (the applicant) and 2 (the compliance reviewer). The
PermitStatus node identifies the status of the form, with values of OPEN (the default
Creating Workflows for Windows SharePoint Services
Page 3 of 16
Tasks Detailed Steps
value), REJECTED, or APPROVED. The PermitAmount node contains the value
that is calculated when the user clicks Calculate Permit Amount.
Note also that there are a number of fields that have been promoted as columns in the
SharePoint library. This promotion is done so that workflow logic can be written
against the form’s data source. Of course, it also allows users to review certain values
in forms in the SharePoint form library without having to open those forms.
a. Select the View | Data Source menu command.
b. In the Data Source task pane, hover over some of the top-level nodes to view the
corresponding data type and default value.
Note: The RoleID default value is 1 and the PermitStatus default value is OPEN.
c. Select the Tools | Forms Options menu command.
d. In the Form Options dialog box, click the Property Promotion category to
review promoted fields.
e. Click Cancel.
f. Close Office InfoPath 2007.
3. Create a new
Workflow in
SharePoint Designer
2007
Note: Now that you have some familiarity with the building permit application form
template, you can begin the task of designing the workflow. The Workflow Designer of
Office SharePoint Designer 2007 has a relatively simple UI that allows users to create
workflow logic for any SharePoint list. Action sets can be added for a workflow
similar to how rules can be added in the Office InfoPath 2007 designer. You can have
actions performed such as assigning a task or sending an e-mail message, and these
actions are executed based on the values of certain promoted fields in the form. You
can even dynamically add the values of promoted form fields to the bodies of e-mail
messages.
In this exercise, you will create a new workflow and associate it with the Building
Permit Application form library. You will use the Workflow Designer to (1) assign a
task to the correct compliance reviewer when a form is first submitted, and (2) send an
e-mail message to the applicant after the form has been reviewed.
a. Navigate to Start | All Programs | Microsoft Office | Microsoft Office
SharePoint Designer 12.
b. If SharePoint Designer does not open to http://moss.litwareinc.com/sites/permits
then click File, Open Site then type http://moss.litwareinc.com/sites/permits,
and click Open. This may take a few minutes to open and for the menu options to
activate.
c. In Microsoft Office SharePoint Designer 2007, select the File | New | Workflow
menu command.
d. In the Workflow Designer, change the SharePoint list value to Building Permit
Application. Leave the Workflow name as Workflow 1.
e. Select the Automatically start this workflow when a new item is created check
box.
f. Select the Automatically start this workflow whenever an item is changed
check box.
g. Click Next.
4. Specify Permit Status
and Define
Workflow Lookup
Note: Workflows are composed of steps, which are composed of action sets. Each
workflow step is processed in the order listed in the Workflow Steps task pane. Action
sets are also processed in the order listed within each step. Processing within a step
stops when one of its action sets evaluates to true. For this exercise, you will create
two action sets: one that assigns a task to a compliance reviewer and one that sends
an e-mail message to the applicant after the form has been reviewed.
The action to assign a task to the compliance reviewer occurs after a form is first
Creating Workflows for Windows SharePoint Services
Page 4 of 16
Tasks Detailed Steps
submitted to the SharePoint form library. If you recall from when you reviewed the
form template’s data source, the PermitStatus node identifies the current review
status of the building permit application. A value of OPEN indicates that the
application has not yet been reviewed, while values of APPROVED and REJECTED
indicate that the reviewer has either approved or rejected the application. Thus, you
will need to add a condition where the Permit Status promoted property value is
OPEN. Once the condition is specified, you use the Actions list to assign a task to the
compliance reviewer. For this set of steps, you will use the Custom Task Wizard to
define a custom task that is assigned to the value of the Reviewer Email promoted
property.
a. In the Workflow Designer, click the Conditions list and select Custom Condition
(Building Permit Application).
b. Click field and select Permit Status.
c. Click value, type OPEN and press ENTER.
d. Click the Actions list and select Assign a Todo Item.
e. Click a todo item.
f. In the first page of the Custom Task Wizard, click Next.
g. Type Review Building Permit Application in the Name field.
h. Type Perform a compliance review for the new building permit application
submitted to the form library in the Description field and click Finish.
i. Click these users.
j. In the Select Users dialog box, click Workflow Lookup in the list box and click
Add.
k. The Define Workflow Lookup dialog box should appear
l. Leave Source section entry with default value of Current Item. Select Reviewer
Email from the Field list in the Lookup Details section.
m. Click OK.
n. In the Select Users dialog box, click OK.
Note: The action to send an e-mail message to the applicant occurs after the
compliance reviewer has either approved or rejected the building permit application.
In the case of an approval, the Permit Status promoted property value changes to
APPROVED, and the applicant would receive an e-mail message identifying the
permit amount that is due to the city of Anytown, MI. If the application is rejected, the
Permit Status promoted property value changes to REJECTED, and the Role ID
value is set to 1. As a result of time constraints, you will build the action set only for
the approval message.
After setting the condition, use the Send an Email action to create the e-mail message
that is to be sent. Because the applicant’s e-mail address is a promoted property, you
can perform a workflow lookup and set the To field in the e-mail message to that
Creating Workflows for Windows SharePoint Services
Page 5 of 16
Tasks Detailed Steps
promoted property’s value. You can use promoted property values in the CC, Subject,
and message body fields as well. For this exercise, you will use the Permit Amount
promoted property value in the message body to indicate the amount owed by the
applicant for the permit.
o. Click Add ‘Else If’ Conditional Branch.
p. Click the new Conditions list and select Custom Condition (Building Permit
Application).
q. Click field and select Permit Status.
r. Click value, type APPROVED and press ENTER.
s. Click the new Actions list and select Send an Email.
t. Click this message.
u. In the Define Email Message dialog box, click the lookup button located to the
right of the To text box.
v. In the Select Users dialog box, click Workflow Lookup in the list box and click
Add.
w. In the Define Workflow Lookup dialog box, select Submitter (Email) from the
Field list in the Lookup Details section and click OK.
x. In the Select Users dialog box, click OK.
y. In the Define Email Message dialog box, type Your Building Permit
Application Has Been Approved in the Subject text box.
z. In the body text box, type The following amount is due to the city of Anytown,
MI, for the building permit: $.
aa. Reposition the cursor between the “$” and the “.” in the body text box. Click Add
Lookup to Body.
bb. In the Define Workflow Lookup dialog box, select Permit Amount from the
Field list in the Lookup Details section.
cc. Click OK.
dd. In the Define Email Message dialog box, click OK. Your workflow step should
now appear
ee. Click Finish to process and validate your changes and save the workflow.
ff. Close Office SharePoint Designer 2007
Creating Workflows for Windows SharePoint Services
Page 6 of 16
Tasks Detailed Steps
5. Test the Workflow Note: To test the workflow, you will need to log on as different users so that you can
simulate the actions of multiple roles. This machine is equipped with remote desktop
connections for NicoleC (the applicant) and DaveR (the reviewer). For the applicant,
a URL is provided for gaining access to the building permit application browser-
based form. The reviewer can access the form as a rich client from the Building
Permit Application form library.
Start the test by logging on as NicoleC. The applicant navigates to the browser-based
version of the building permit application and provides details about the project in the
form. Note that the individual to whom an associated design drawing is sent is
dependent on the value of the PROJECT TYPE list. For this exercise, you will not
have to submit a design drawing.
After all information has been provided, the applicant submits the data, which sends
the form file to the Building Permit Application form library and kicks off the
associated workflow that you created in the previous set of steps.
a. Double-click the Nicole Caron remote desktop connection shortcut on the
desktop.
b. In Internet Explorer, navigate to Favorites | Building Permit Application Form.
c. When the form starts, type R12-34567 in the Lot # text box and click Retrieve
Data to populate the property and owner fields.
d. Select Building Extension in the PROJECT TYPE list.
e. In the PROJECT ESTIMATES section, select 7/24/2006 as a Start Date and
7/28/2006 as an End Date.
f. Type 500 in the Size text box.
g. Type 12000 in the Cost text box.
h. Click Calculate Permit Amount.
i. Click Submit.
j. In the Microsoft Internet Explorer dialog box, click OK to confirm that the form
was submitted successfully.
k. Minimize the Nicole Caron remote desktop connection.
Note: Now, as the compliance reviewer (DaveR), you will navigate to your task list to
see if any tasks have been assigned. You can click the Title link in the task list to view
some of the task details. For now, you will navigate to the Building Permit
Application form library to review the new application from NicoleC.
From the form library, you can click the Name link to start the building permit
application form in the rich client. Because you still want to test whether the second
action set in your workflow is performing correctly, click Approved or NA for all of
the compliance items in the INTERNAL USE ONLY section. As long as none of these
items are set to Rejected, the form’s permit status value will change to APPROVED
on submit.
l. Double-click the Dave Richards remote desktop connection shortcut on the
desktop.
m. In Internet Explorer, navigate to Favorites | My Task List.
n. Click the link in the Link column of the Review Building Permit Application
task, if you are prompted to Open or Save choose to Open the file.
o. In the INTERNAL USE ONLY section of the form, click Approved or NA for
all compliance review items and click Submit.
Creating Workflows for Windows SharePoint Services
Page 7 of 16
Tasks Detailed Steps
p. In the Microsoft Office InfoPath dialog box, click OK to confirm that the form
was submitted successfully, if you are prompted to save you changes select no as
the submit has already saved them.
q. Minimize the Dave Richards remote desktop connection.
6. Verify the e-mail
was sent Note: The last task in this exercise is to confirm that an e-mail message was sent to the
applicant after the compliance reviewer approved the building permit application. You
can switch back to the NicoleC remote desktop connection and start Office Outlook
2007 to confirm receipt of the approval message. Within the body of that message,
note how the workflow lookup value (for the Permit Amount promoted property) is
resolved to 1500.
a. Maximize the Nicole Caron remote desktop connection.
b. Navigate to Start | All Programs | Microsoft Office | Microsoft Office Outlook
12.
c. Click Send/Receive.
Note: There may be a bug in this beta 2007 release that prevents workflow e-mail
messages from being sent.
d. Preview the message with the subject Your Building Permit Application Has
Been Approved.
Creating Workflows for Windows SharePoint Services
Page 8 of 16
Exercise 2 Building a Custom Workflow with Visual Studio
Scenario The Microsoft Office SharePoint Server 2007 Workflow Developer Starter Kit installs additional project templates and a Toolbox and Designer that developers can use to build custom Microsoft Office SharePoint Server 2007 workflows.
In this exercise you will create a new managed-code Workflow project using Microsoft Visual Studio 2005 with the Microsoft Office SharePoint Server 2007 Workflow Developer Starter Kit and deploy the workflow to a Microsoft Office SharePoint Server.
m. While still in Windows Explorer, double-click MyInstall.cmd in the Deployment
folder to start deployment of the workflow to SharePoint
Note: The following warning is normal on first run:
Object reference not set to an instance of an object.
Feature 'fb0e52e0-a7da-11da-a746-0800200c9a66' is not installed in this farm.
If no other errors appear, deployment was successful.
4. Edit the Workflow
Settings
a. Launch Internet Explorer.
b. Enter http://moss.litwareinc.com/sites/workflow and click Orders from the
Quick Launch pane to open the document library.
c. Click Settings | Document Library Settings and under Permissions and Policies
click Workflow settings.
d. In the Select a workflow template list, click Order Request Workflow and type
Creating Workflows for Windows SharePoint Services
Page 16 of 16
Tasks Detailed Steps
Order Request Workflow as the unique name for the workflow.
e. Leave the defaults for the rest of the form.
f. Click Next and click Submit on the page that follows.
g. Click on the breadcrumb at the top of the page to return to Orders.
5. Test the Workflow a. In the Orders library, hover the mouse over the AdventureWorks Q1 2003
document, click the arrow and select Workflows in the context menu.
b. Under Start a New Workflow, click Order Request Workflow.
c. Once the form has been posted you are returned to the Orders library.
d. Notice the column Order Request Workflow states that a workflow for the
document is In Progress.
e. Select Tasks from the Quick Launch pane.
f. Click the New Order Request list item to review the request.
g. Change the Status to Complete and click Update.
h. You are returned to the Tasks list and the task Status is now marked Completed.
i. Click Orders to return to the document library.
j. Notice the Order Request Workflow column now states that the workflow for the
document is Completed.
Conclusion
In this lab, you used Microsoft Office SharePoint Designer 2007 to design a custom workflow triggered on file creation or change. Within the workflow designer, you used out-of-the-box actions such as assigning a task or sending an e-mail message based on promoted values in your form data. In addition, you learned how to build a custom workflow using the Windows Workflow Foundation plug-in to Microsoft Visual Studio 2005 and deploy that workflow to Windows SharePoint Services (version 3). Both exercises demonstrated how workflow functionality can be seamlessly integrated with the 2007 Microsoft® Office System release.