Exercise 2: Building workflows with SharePoint Designer 2010

In this exercise you will import the Visio workflow into SharePoint Designer and complete it. This includes defining the parameters of each step as well as adding some new steps. In the end you will publish your complete workflow and export it back to Visio.

  1. Launch Microsoft Office SharePoint Designer 2010 and open the lab site at http://intranet.contoso.com/sites/Lab07 using the Open Site button on the main page.
  2. Click the Workflows item on the Navigation links on the left hand side of the window to display the current Workflows.

    Figure 1

    The available workflows in SharePoint Designer 2010

  3. Click the Import from Visio button in the ribbon and select the file C:\Student\Labs\07_Workflow\TimeSheet Submission Workflow.vwi and then click Next.
    1. Verify the Name is Timesheet Submission Workflow.
    2. Choose the Reusable Workflow option and select the Time Sheet content type.

      Figure 2

      Import Workflow from Visio Drawing

    3. Click Finish to import the workflow. This can take a while.

      Figure 3

      The workflow in SharePoint Designer 2010

  4. Add two new local variables to store the maximum hours before approval is required and the employee name and set it. For now we’ll store the employee id instead of the name. We’ll look up the employee name in a later exercise.
    1. Click the Local Variables button in the Workflow ribbon.
    2. In the dialog, click the Add button and create a new variable with a name of EmployeeName.
    3. Set the Type to String.
    4. Click OK on all dialogs to create the variable.
    5. Repeat the above steps to create a variable named MaxHours of type Integer.
  5. Store the EmployeeID as the employee’s name. This will be replaced later with the employee’s real name requested from the HR system.
    1. Place the selector at the top of the main step.
    2. Click the Action button in the Workflow ribbon and select Set Workflow Variable.

      Figure 4

      Set Workflow Variable

    3. Click the workflow variable link and select Variable: EmployeeName.
    4. Click the value link and then click the fx button.
    5. In the dialog select EmployeeID in the Field from source drop down list.

      Figure 5

      Lookup for String

    6. Click OK to close the dialog.
  6. Store 40 in the MaxHours variable.
    1. Place the selector just below the action you just added, but before the first If statement.
    2. Click the Action button in the Workflow ribbon and select Set Workflow Variable.
    3. Click the workflow variable link and select Variable: MaxHours.
    4. Click the value link type in 40.
  7. Define a condition that will be true if the number of hours worked is greater than MaxHours.
    1. Click the first value link in the If statement then click the fx button to assign a value.
    2. Leave Data Source as Current Item and select Hours in the Field from source drop down list. Click OK when you are done.
    3. Click this test and select is greater than.
    4. Click the second value link in the If statement then click the fx button to assign a value.
    5. Set Data Source to Workflow Variables and Parameters.
    6. Set Field from source to Variable: MaxHours.
    7. Click OK to close the dialog.
  8. Define the message logged when a timesheet requires manager approval.
    1. Click the this message link on the first Log action that immediately follows the If condition.
    2. Click the button to define the text of the logged message.
    3. Enter the text The time sheet for .
    4. Click Add or Change Lookup to retrieve information from the environment.
      1. Select Workflow Variables and Parameters in the Data Source drop down list.
      2. Select Variable: EmployeeName in the Field from source drop down list.
      3. Click OK to close the dialog.
    5. Finish the message by entering requires manager approval.
    6. Click OK to close the dialog.

      Figure 6

      Configure the workflow

  9. Repeat the previous step for the second Log action with the following exceptions
    1. When finishing the message instead of entering requires manager approval, enter does not require manager approval.
  10. Log that the time sheet has been approved and submitted to HR. It hasn’t actually been submitted at this point, that will happen in a later exercise.
    1. Click the this message link on the final Log actions.
    2. Click the button and enter the message The time sheet has been submitted to HR.
    3. Click OK to close the dialog.

      Figure 7

      Configure the workflow

  11. Finish the workflow’s final settings and publish it to the SharePoint site.
    1. Click the first Timesheet Submission Workflow item on the workflow header to return to the workflow’s home page.

      Figure 8

      Publish the workflow

    2. Check the Show workflow visualization on status page check box (found in the Settings group).

      Figure 9

      Show workflow visualization on status page

    3. Click the Save button to save the workflow settings.
    4. Click the Publish button in the ribbon to publish the workflow to the SharePoint site.

      Figure 10

      Publish the workflow to SharePoint

    5. Click the Associate to List button in the ribbon and select Time Sheets.

      If the list of types is blank when clicking this button, you may need to Save the workflow, and then click the Content Types (i.e. any other section) section in the left-hand Navigation section of SharePoint Designer 2010 to refresh the list types. Then you can go back to the workflow you created and repeat this step.

      Figure 11

      Associate the workflow

    6. When the browser window loads:
      1. In the Content Type section, set Run on items of this type: to Time Sheet.
      2. In the Workflow section, set Select a workflow template: to TimeSheet Submission Workflow.
      3. Set the Name of the workflow to TimeSheet Submission
      4. Leave the others at their default settings, scroll to the bottom and click OK.
  12. Verify that the Visio Web Access farm feature is activated.
    1. Open SharePoint 2010 Central Administration.
    2. On the Central Administration page, select the Manage Farm Feature hyperlink in the System Settings section.
    3. Scroll down and locate the Visio Web Access feature.
    4. If the feature is not activated, click the Activate button.
  13. Return to the Internet Explorer page pointing to http://intranet.contoso.com/sites/Lab07.
  14. Click the link in the quick launch bar for Time Sheets.
  15. Select the Documents ribbon tab and Click on the New Document button and add some sample text to it.
  16. Save the new document to the Time Sheets document library with a File name of Test1.(Note: if you are not given the chance to set these during the save process, you will need to do this by editing the documents properties in SharePoint (i.e. document’s drop down menu and click on Edit Properties)
    1. When saving the document, set the EmployeeID to 1.
    2. Set the Hours to 38.
    3. In the document library select the new document’s drop down menu and click Workflows.
    4. Click Timesheet Submission Workflow to start the new workflow.
    5. On the Initiation page click Start to start the workflow, wait for the workflow to finish Processing…
    6. Once the workflow has started, and has returned you back to the Time Sheets list, click the Completed link for the item.
    7. View the Workflow Information page and see that the steps in the workflow were completed.
    8. Repeat the process if you’d like to try using a Time Sheet that has hours that are greater than 40. Keep in mind that you’ll now have to approve the task that is created.

      Figure 12

      The workflow history

  17. Since the process was changed by your work in SharePoint Designer, export those changes back to Visio to keep the process models in sync.
    1. Switch back to SharePoint Designer and verify the workflow is still in the active window.
    2. Click the Export to Visio button in the ribbon.
    3. Save the updated .vwi file to C:\Student\Labs\07_Workflow\Timesheet Submission Workflow.vwi.(Note: you will likely have to overwrite the existing one to “synchronize” the visio document.)
  18. Switch back to Visio and import the updated .vwi file.
    1. Click the Import button in the Process ribbon tab.
    2. Select the C:\Student\Labs\07_Workflow\Solution\Timesheet Submission Workflow.vwi file.
    3. The Visio diagram should now be updated to include the Set Workflow Variable tasks added in SharePoint Designer.

      Figure 13

      The updated Visio diagram

In this exercise you imported a workflow created in Visio 2010 into SharePoint Designer, made a few changes and then deployed it to SharePoint. You then sync’d those changes with the original Visio diagram.