Exercise 2: Completing a Process in SharePoint 2010
In this exercise you will import the process exported from Visio and fill in the design details to create a complete workflow.
Task 1 – Import the Visio process
In this first task, you will import the new process from Visio and create a new SharePoint Designer workflow attached to the Timesheet content type.
- Open the target SharePoint site in SharePoint Designer
- Using Internet Explorer navigate to https://intranet.contoso.com/sites/ClientWorkflow
- Click Site Actions -> Site Settings
- On the Site Settings page, click the Site collection features link
Activate the SharePoint Server Enterprise Site Collection features feature
Figure 8
Activated Site Collection Feature
- Navigate back to the Site Settings page using Site Actions -> Site Settings
- Click the Manage site features link
Activate the SharePoint Server Enterprise Site features feature
Figure 9
Activated Site Feature
Click Site Actions -> Edit Site in SharePoint Designer
Figure 10
Edit in SharePoint Designer
- Create a new workflow imported from Visio
- Switch to the Workflows view using the Navigation bar on the left
- Click the Import from Visio button in the Workflows ribbon tab
- Browse to the Timesheet Approval.vwi file in the %Office2010DeveloperTrainingKitPath%\Labs\ClientWorkflow\Source\[language]\Starter folder
- Click Next to move to the next page of the wizard
- Select the Reusable Workflow radio button
Choose Timesheet in the content type drop down list
Figure 11
Import Workflow Dialog
Click Finish to create the new workflow
Figure 12
Imported Workflow
Task 2 – Complete the imported process
In this task, you will use the process outline created by importing the Visio diagram as a starting point. You will provide details to each task to complete the approval workflow.
- Fill in the Check for Overtime task to check if the timesheet contains overtime hours
- In the If statement under Check for Overtime, click the field link
- Choose Overtime Hours in the field drop down list
- Click the equals link and set it to is greater than
Click value and enter 0
Figure 13
Check if overtime approved
- Initialize Send to Manager for Approval task
- In the action under Send to Manager for Approval click the this item link
- In the Choose List Item dialog, select Current Item and click OK
- Define a custom Title to the approval message the manager receives
- Click the these users link
- Enter CONTOSO\Administrator in the Participants text box
- Click the … button by the Title text box
- Enter the text Overtime approval for into the text box
- Click the Add or Change Lookup button
- Select Employees in the Data source drop down list
- Select Full Name in the Field from source drop down list
Select ID in the Field drop down list
Figure 14
Lookup Employee Full Name
- Click the fx button by the Value text box
- In the dialog, choose Employee in the Field from source
Choose Lookup Id (as integer) in the Return field as drop down list
Figure 15
Choose Employee ID
Click both OK buttons to return to the Select Task Process Participants dialog
Figure 16
Completed Approval subject
- Define a custom message for the approval sent to the manager
- Place the cursor into the Instructions text box
- Click the Add or Change Lookup button
- Choose Overtime Hours in the Fieldfrom source drop down list
- Click OK to close the dialog
- Add the following text after the lookup hours of overtime need approval
Click OK to complete the approval message definition
Figure 17
Completed Approval Definition
- Update the Approval process to set an OvertimeApproved variable indicating the result
- Click the Local Variables button on the Workflow ribbon tab
- Click the Add button to add a new variable
Set the Name to OvertimeApproved and the Type to Boolean
Figure 18
Add Overtime Approved Variable
- Click OK to create the new variable and click OK again to close the variables dialog
- Click the Approval Process link in the Send to Manager for Approval action
- Click the Change the behavior of a single task in the Customization section
- Locate the When a Task Completes section
Place the cursor after the first Log action and type Set Workflow Variable and press Enter
Figure 19
On Task Completes Actions
- Click the workflow variable link and choose Variable: OvertimeApproved
- Click the value link and choose Yes
Repeat this process following the second Log action and set the variable to No
Figure 20
Overtime Approved Variable Set
- Check the result of the approval and clear overtime hours if they were not approved
Navigate back to the primary workflow by clicking the Editor link in the header of the window
Figure 21
Navigation to Workflow Editor
- In the Check for ApprovalIf statement, click the first value link
- Click the fx button
- Set Data source to Workflow Variables and Parameters
Set Fields from source to Variable: OvertimeApproved
Figure 22
Lookup Overtime Approved Variable
- Click OK to close the dialog
- Click the this test link and choose equals
Click value and choose Yes
Figure 23
Check if approval is complete
- Click the field link in the Clear Overtime Set action and choose Overtime Hours
Click the value link and set it to 0
Figure 24
Clear overtime hours
- Set the workflow’s state to processed indicating the process is completed
- Place the cursor after the Check for Overtime if statement and type Set workflow status and press enter
Click the Canceled link and type Processed
Figure 25
Set workflow status
- Change the workflow settings to show the Visio document in the status page and publish it to SharePoint
- Click the Workflow Settings link on the Workflow ribbon tab
- Check the Show workflow visualizationon status page checkbox
- Click the Publish button on the Workflow Settings ribbon tab
- Once the publish is complete, click Association to Content Type in the Workflow Settings ribbon tab and choose Timesheet
- Click OK to create the new workflow association
Exercise 2 Verification
In order to verify that you have correctly performed all steps of exercise 2, proceed as follows:
Test the Timesheet
Test your Timesheet.
- Create a new Timesheet to approve
- In Internet Explorer navigate to https://intranet.contoso.com/sites/ClientWorkflow
- Click the Timesheets link in the navigation menu
- Create a new timesheet entry with less than 0 overtime hours
- Click the New Item in the Items ribbon tab
- Create a new item with the following items
- Title – Amy Alberts Timesheet
- Employee – Amy Alberts
- Monday thru Friday Hours – 8
- Total Hours – 40
- Overtime Hours – 0
- Select the new item in the list and click the Workflows button in its drop down menu
- In the Workflow page, click Timesheet Approval
- In the initiation page, click Start to start the workflow
Click the Processed link to view the status
Figure 26
Completed with no Overtime
Notice that the workflow completed immediately since there were no overtime hours reported
- Create a new timesheet entry with more than 0 overtime hours
- Click the New Item in the Items ribbon tab
- Create a new item with the following items
- Title – Alan Brewer Timesheet
- Employee – Alan Brewer
- Monday thru Thursday Hours – 8
- Friday Hours - 9
- Total Hours – 40
- Overtime Hours – 1
- Select the new item in the list and click the Workflows button in its drop down menu
- In the Workflow page, click Timesheet Approval
- In the initiation page, click Start to start the workflow
Click the In Progress link to view the status
Figure 27
Awaiting Overtime Approval
- Click Edit Item in the Task’s drop down menu
In the task form, click the Reject button
Figure 28
Approve Overtime Task
When the task completes, navigate to the Timesheets list and verify the entry has no overtime hours
Figure 29
Overtime Hours Cleared