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.

  1. Open the target SharePoint site in SharePoint Designer
    1. Using Internet Explorer navigate to https://intranet.contoso.com/sites/ClientWorkflow
    2. Click Site Actions -> Site Settings
    3. On the Site Settings page, click the Site collection features link
    4. Activate the SharePoint Server Enterprise Site Collection features feature

      Figure 8

      Activated Site Collection Feature

    5. Navigate back to the Site Settings page using Site Actions -> Site Settings
    6. Click the Manage site features link
    7. Activate the SharePoint Server Enterprise Site features feature

      Figure 9

      Activated Site Feature

    8. Click Site Actions -> Edit Site in SharePoint Designer

      Figure 10

      Edit in SharePoint Designer

  2. Create a new workflow imported from Visio
    1. Switch to the Workflows view using the Navigation bar on the left
    2. Click the Import from Visio button in the Workflows ribbon tab
    3. Browse to the Timesheet Approval.vwi file in the %Office2010DeveloperTrainingKitPath%\Labs\ClientWorkflow\Source\[language]\Starter folder
    4. Click Next to move to the next page of the wizard
    5. Select the Reusable Workflow radio button
    6. Choose Timesheet in the content type drop down list

      Figure 11

      Import Workflow Dialog

    7. 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.

  1. Fill in the Check for Overtime task to check if the timesheet contains overtime hours
    1. In the If statement under Check for Overtime, click the field link
    2. Choose Overtime Hours in the field drop down list
    3. Click the equals link and set it to is greater than
    4. Click value and enter 0

      Figure 13

      Check if overtime approved

  2. Initialize Send to Manager for Approval task
    1. In the action under Send to Manager for Approval click the this item link
    2. In the Choose List Item dialog, select Current Item and click OK
  3. Define a custom Title to the approval message the manager receives
    1. Click the these users link
    2. Enter CONTOSO\Administrator in the Participants text box
    3. Click the button by the Title text box
    4. Enter the text Overtime approval for into the text box
    5. Click the Add or Change Lookup button
    6. Select Employees in the Data source drop down list
    7. Select Full Name in the Field from source drop down list
    8. Select ID in the Field drop down list

      Figure 14

      Lookup Employee Full Name

    9. Click the fx button by the Value text box
    10. In the dialog, choose Employee in the Field from source
    11. Choose Lookup Id (as integer) in the Return field as drop down list

      Figure 15

      Choose Employee ID

    12. Click both OK buttons to return to the Select Task Process Participants dialog

      Figure 16

      Completed Approval subject

    13. Define a custom message for the approval sent to the manager
    14. Place the cursor into the Instructions text box
    15. Click the Add or Change Lookup button
    16. Choose Overtime Hours in the Fieldfrom source drop down list
    17. Click OK to close the dialog
    18. Add the following text after the lookup hours of overtime need approval
    19. Click OK to complete the approval message definition

      Figure 17

      Completed Approval Definition

  4. Update the Approval process to set an OvertimeApproved variable indicating the result
    1. Click the Local Variables button on the Workflow ribbon tab
    2. Click the Add button to add a new variable
    3. Set the Name to OvertimeApproved and the Type to Boolean

      Figure 18

      Add Overtime Approved Variable

    4. Click OK to create the new variable and click OK again to close the variables dialog
    5. Click the Approval Process link in the Send to Manager for Approval action
    6. Click the Change the behavior of a single task in the Customization section
    7. Locate the When a Task Completes section
    8. Place the cursor after the first Log action and type Set Workflow Variable and press Enter

      Figure 19

      On Task Completes Actions

    9. Click the workflow variable link and choose Variable: OvertimeApproved
    10. Click the value link and choose Yes
    11. Repeat this process following the second Log action and set the variable to No

      Figure 20

      Overtime Approved Variable Set

  5. Check the result of the approval and clear overtime hours if they were not approved
    1. Navigate back to the primary workflow by clicking the Editor link in the header of the window

      Figure 21

      Navigation to Workflow Editor

    2. In the Check for ApprovalIf statement, click the first value link
    3. Click the fx button
    4. Set Data source to Workflow Variables and Parameters
    5. Set Fields from source to Variable: OvertimeApproved

      Figure 22

      Lookup Overtime Approved Variable

    6. Click OK to close the dialog
    7. Click the this test link and choose equals
    8. Click value and choose Yes

      Figure 23

      Check if approval is complete

    9. Click the field link in the Clear Overtime Set action and choose Overtime Hours
    10. Click the value link and set it to 0

      Figure 24

      Clear overtime hours

  6. Set the workflow’s state to processed indicating the process is completed
    1. Place the cursor after the Check for Overtime if statement and type Set workflow status and press enter
    2. Click the Canceled link and type Processed

      Figure 25

      Set workflow status

  7. Change the workflow settings to show the Visio document in the status page and publish it to SharePoint
    1. Click the Workflow Settings link on the Workflow ribbon tab
    2. Check the Show workflow visualizationon status page checkbox
    3. Click the Publish button on the Workflow Settings ribbon tab
    4. Once the publish is complete, click Association to Content Type in the Workflow Settings ribbon tab and choose Timesheet
    5. 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.

  1. Create a new Timesheet to approve
    1. In Internet Explorer navigate to https://intranet.contoso.com/sites/ClientWorkflow
    2. Click the Timesheets link in the navigation menu
  2. Create a new timesheet entry with less than 0 overtime hours
    1. Click the New Item in the Items ribbon tab
    2. Create a new item with the following items
      1. Title – Amy Alberts Timesheet
      2. Employee – Amy Alberts
      3. Monday thru Friday Hours – 8
      4. Total Hours – 40
      5. Overtime Hours – 0
    3. Select the new item in the list and click the Workflows button in its drop down menu
    4. In the Workflow page, click Timesheet Approval
    5. In the initiation page, click Start to start the workflow
    6. Click the Processed link to view the status

      Figure 26

      Completed with no Overtime

      Note:
      Notice that the workflow completed immediately since there were no overtime hours reported

  3. Create a new timesheet entry with more than 0 overtime hours
    1. Click the New Item in the Items ribbon tab
    2. Create a new item with the following items
      1. Title – Alan Brewer Timesheet
      2. Employee – Alan Brewer
      3. Monday thru Thursday Hours – 8
      4. Friday Hours - 9
      5. Total Hours – 40
      6. Overtime Hours – 1
    3. Select the new item in the list and click the Workflows button in its drop down menu
    4. In the Workflow page, click Timesheet Approval
    5. In the initiation page, click Start to start the workflow
    6. Click the In Progress link to view the status

      Figure 27

      Awaiting Overtime Approval

    7. Click Edit Item in the Task’s drop down menu
    8. In the task form, click the Reject button

      Figure 28

      Approve Overtime Task

    9. When the task completes, navigate to the Timesheets list and verify the entry has no overtime hours

      Figure 29

      Overtime Hours Cleared