Hands-On Lab. Client Workflow. Lab version: 1.0.0 Last updated: 2/23/2011

Similar documents
Appendix A How to create a data-sharing lab

Hands-On Lab. Building a Data-Driven Master/Detail Business Form using Visual Studio Lab version: Last updated: 12/10/2010.

Learn how to create web enabled (browser) forms in InfoPath 2013 and publish them in SharePoint InfoPath 2013 Web Enabled (Browser) forms

A SharePoint Developer Introduction

IBM BPM V8.5 Standard Consistent Document Managment

Table of Contents. 1. Content Approval...1 EVALUATION COPY

DEPLOYING A VISUAL BASIC.NET APPLICATION

Nintex Workflow 2010 Installation Guide. Installation Guide Nintex USA LLC, All rights reserved. Errors and omissions excepted.

Microsoft Office System Tip Sheet

Walkthrough: Creating and Using an ASP.NET Web Service in Visual Web Developer

Nintex Workflow 2010 Help Last updated: Friday, 26 November 2010

How to install and use the File Sharing Outlook Plugin

Appendix E. Captioning Manager system requirements. Installing the Captioning Manager

Hands-On Lab. Web Development in Visual Studio Lab version: Last updated: 12/10/2010. Page 1

Sitecore is a trademark of Sitecore A/S. All other brand and product names are the property of their respective holders.

SPHOL326: Designing a SharePoint 2013 Site. Hands-On Lab. Lab Manual

Kaldeera Workflow Designer 2010 User's Guide

Bitrix Site Manager ASP.NET. Installation Guide

Installing LearningBay Enterprise Part 2

Microsoft Office Access 2007 Basics

IBM Operational Decision Manager Version 8 Release 5. Getting Started with Business Rules

Colligo Contributor File Manager 4.6. User Guide

DocuSign for SharePoint

ProperSync 1.3 User Manual. Rev 1.2

Microsoft Access 2010 handout

Getting started with 2c8 plugin for Microsoft Sharepoint Server 2010

Building and Using Web Services With JDeveloper 11g

Microsoft Outlook 2013 Workshop

owncloud Configuration and Usage Guide

How To Integrate SAP Business Data Into SharePoint 2010 Using Business Connectivity Services And LINQ to SAP

TECHNICAL DOCUMENTATION SPECOPS DEPLOY / APP 4.7 DOCUMENTATION

NSi Mobile Installation Guide. Version 6.2

Outlook . Step 1: Open and Configure Outlook

Creating Dashboards for Microsoft Project Server 2010

How to Back Up and Restore an ACT! Database Answer ID 19211

MICROSOFT OUTLOOK 2011 GETTING STARTED AND HELP RESOURCES

SPHOL207: Database Snapshots with SharePoint 2013

A SharePoint Developer Introduction. Hands-On Lab. Lab Manual SPCHOL306 Using Silverlight with the Client Object Model VB

14.1. bs^ir^qfkd=obcib`qflk= Ñçê=emI=rkfuI=~åÇ=léÉåsjp=eçëíë

Step-By-Step build Advanced InfoPath Form and SharePoint Designer Workflow

Create a New Database in Access 2010

You must have at least Editor access to your own mail database to run archiving.

BACKING UP DATA FROM VIRTUAL OFFICE CS OR SAAS APPLICATIONS

Business Portal for Microsoft Dynamics GP Project Time and Expense User s Guide

SQL Server 2005: Report Builder

Quick Start Guide. Microsoft Access 2013 looks different from previous versions, so we created this guide to help you minimize the learning curve.

Outlook 2007: Managing your mailbox

Tenrox and Microsoft Dynamics CRM Integration Guide

Create a new investment form and publish it to a SharePoint 2013 forms library

Mitigation Planning Portal MPP Reporting System

Shasta College SharePoint Tutorial. Create an HTML Form

Authoring for System Center 2012 Operations Manager

Organizing and Managing

Microsoft SharePoint 2010 End User Quick Reference Card

Extensibility. vcloud Automation Center 6.0 EN

Microsoft Access 2007

Archive Attender Version 3.5

NETWRIX EVENT LOG MANAGER

UNICORN 6.4. Administration and Technical Manual

Releasing blocked in Data Security

User Guide. Please visit the Helpdesk website for more information:

Report Designer and Report Designer Add-In Installation Guide Version 1.0

Visualization with Excel Tools and Microsoft Azure

SQL Server 2005 Advanced settings

Colligo Manager 6.0. Offline Mode - User Guide

Installation Guide. . All right reserved. For more information about Specops Deploy and other Specops products, visit

SP Term Cloud Installation

INTRODUCTION 5 COLLABORATION RIBBON 5 SELECT THE UPDATING METHOD 6 MAKE YOUR PROJECT COLLABORATIVE 8 PROCESSING RECEIVED TASK UPDATES 9

Outlook . User Guide IS TRAINING CENTER. 833 Chestnut St, Suite 600. Philadelphia, PA

Word 2010: Mail Merge to with Attachments

Working with SQL Server Integration Services

Clean Up Rules Quick Steps Search Tools Change Views Export Data Convert to tasks Contact Groups. Outlook Functions

Composite.Community.Newsletter - User Guide

Install the Production Treasury Root Certificate (Vista / Win 7)

Quick Start Guide. Microsoft Access 2013 looks different from previous versions, so we created this guide to help you minimize the learning curve.

ThirtySix Software WRITE ONCE. APPROVE ONCE. USE EVERYWHERE. SMARTDOCS SHAREPOINT CONFIGURATION GUIDE THIRTYSIX SOFTWARE

BID2WIN Workshop. Advanced Report Writing

CRM Setup Factory Installer V 3.0 Developers Guide

Results CRM 2012 User Manual

What is a workflow? Workflows are a series of actions that correspond to a work process

SETUP SSL IN SHAREPOINT 2013 (USING SELF-SIGNED CERTIFICATE)

ENHANCE. The Style Sheet Tool for Microsoft Dynamics NAV. Microsoft Dynamics NAV 5.0. User s Guide

Administrator s Plus. Backup Process. A Get Started Guide

SonicWALL CDP Local Archiving

UF Health SharePoint 2010 Document Libraries

Optional Lab: Schedule Task Using GUI and at Command in Windows 7

ADFS Integration Guidelines

Advanced Workflow Concepts Using SharePoint Designer 2010

Outlook Tips & Tricks. Training For Current & New Employees

Microsoft Corporation. Project Server 2010 Installation Guide

Nintex Workflow 2013 Help

Microsoft Visual Studio Integration Guide

Lab 8: ASP.NET 2.0 Configuration API and Health Monitoring

Microsoft Office Access 2007 which I refer to as Access throughout this book

Subscribe to RSS in Outlook Find RSS Feeds. Exchange Outlook 2007 How To s / RSS Feeds 1of 7

DocAve 6 Service Pack 1 Job Monitor

Microsoft Access 2010 Part 1: Introduction to Access

5.6.2 Optional Lab: Restore Points in Windows Vista

Transitioning from TurningPoint 5 to TurningPoint Cloud - LMS 1

Transcription:

Hands-On Lab Client Workflow Lab version: 1.0.0 Last updated: 2/23/2011

CONTENTS OVERVIEW... 3 EXERCISE 1: DEFINING A PROCESS IN VISIO 2010... 4 Task 1 Define the Timesheet Approval process... 4 Task 2 Export the process to SharePoint Designer... 7 EXERCISE 2: COMPLETING A PROCESS IN SHAREPOINT 2010... 8 Task 1 Import the Visio process... 8 Task 2 Complete the imported process... 10 Exercise 2 Verification... 16 EXERCISE 3: BUILDING A WORKFLOW IN VISUAL STUDIO 2010... 19 Task 1 Create a new Visual Studio 2010 Sequential Workflow... 19 Task 2 Create the custom Association page... 23 Task 3 Implement the TimeSheet generation workflow... 27 Exercise 3 Verification... 29 SUMMARY... 31 APPENDIX... 32 No Items 32

Overview In this lab exercise, you will build a workflow process using Visio 2010, SharePoint Designer 2010 and Visual Studio 2010. The end goal of the workflow process is to approve timesheet submission. The employee will submit an entry. The process will examine several fields and end up with an approved timesheet. At this point, the data is used to generate a Word document containing a printable version of the timesheet. Objectives In this lab you will: Learn to build declarative workflows using Visio 2010 and SharePoint Designer 2010 Learn to build a workflow in Visual Studio 2010 System Requirements This lab assumes that you have SharePoint Server installed in a test environment. For guidance on how to setup SharePoint Server see http://msdn.microsoft.com/en-us/library/ee554869(office.14).aspx. Note that any URL referred to in this lab must be adjusted for use with your local setup. You must have the following items to complete this lab: Microsoft Windows Vista SP1 or Microsoft Windows Server 2008 (64-bit) Microsoft SharePoint Server 2010 (64-bit) Microsoft Office Professional Plus 2010 (32-bit or 64-bit) Microsoft Visual Studio 2010 Setup You must perform the following steps to prepare your computer for this lab. This consists primarily of creating a SharePoint site collection at http://intranet.contoso.com/sites/clientworkflow and installing the code snippets for this lab. 1. Run the command file Setup.bat located at C:\Office2010DeveloperTrainingKit\Labs\ClientWorkflow\Source\.

Visual Studio solutions. The lab provides a Source folder. The lab instructions assume that you installed the training kit to the default location, C:\Office2010DeveloperTrainingKit\. Note: Inside the lab s Source folder, you will find a Solution folder containing an end solution with the completed lab exercise. Exercises This Hands-On Lab is comprised of one exercise with the following tasks: 1. Defining a process in Visio 2010 2. Completing a process in SharePoint Designer 2010 3. Building a Workflow in Visual Studio 2010 Estimated time to complete this lab: 60 minutes. Exercise 1: Defining a Process in Visio 2010 In this exercise you will use the Visio SharePoint Workflow template to define a process outline of the Timesheet Approval process. This model can be exported to SharePoint Designer and server as a starting point for the completion of the process. Task 1 Define the Timesheet Approval process In this first task, you will define the process in Visio 2010 using the SharePoint Workflow template 1. Open Visio 2010 and create a new SharePoint Workflow drawing a. Open Visio 2010 b. Choose the Flowchart template category and select the Microsoft SharePoint Workflow template c. Click the Create button to create the new drawing

Figure 1 Create new SharePoint Workflow 2. Add the Start and Terminate shapes to define the beginning and end of the process a. Select the Quick Shapes section in the Shapes task pane b. Drag a Start shape onto the new drawing c. Drag a Terminate shape onto the new drawing 3. Add a Compare document field shape to check if the timesheet includes overtime a. Select the SharePoint Workflow Conditions section in the Shapes task pane b. Drag a Compare document field shape onto the drawing c. Set the shape s name to Check for Overtime Figure 2 Check for Overtime shape 4. Add an Assign item for approval shape to submit the timesheet to the manager for approval a. Select the SharePoint Workflow Actions section in the Shapes task pane b. Drag a Start approval process shape onto the drawing

c. Set the shape s name to Send to Manager for Approval Figure 3 Send to Manager for Approval shape 5. Add a Compare data source shape to check the results of the manager s approval a. Select the SharePoint Workflow Conditions section in the Shapes task pane b. Drag a Compare data source shape onto the drawing c. Set the shape s name to Check for Approval Figure 4 Check for Approval shape 6. Add a Set field shape to clear overtime if the manager rejected the overtime a. Select the SharePoint Workflow Actions section in the Shapes task pane b. Drag a Set field shape onto the drawing c. Set the shape s name to Clear Overtime Figure 5 Clear Overtime shape 7. Connect the shapes to define flow of control a. Connect the Start shape to Check for Overtime b. Connect Check for Overtime to Send to Manager for Approval c. Connect Check for Overtime to the Terminate shape

d. Connect Send to Manager for Approval to Check for Approval e. Connect Check for Approval to Clear Overtime f. Connect Check for Approval to the Terminate shape g. Connect Clear Overtime to the Terminate shape Figure 6 Shape connection 8. Update all connections from decisions to be marked yes or no a. Right click the connection between Check for Overtime and Send to Manager for Approval and choose Yes b. Mark the connection between Check for Overtime and the Terminate shape as No c. Mark the connection between Check for Approval and the Terminate shape as Yes d. Mark the connection between Check for Approval and Clear Overtime as No e. Update the drawing s layout to make it look like the image below Figure 7 Shape connections with choices Task 2 Export the process to SharePoint Designer In this task, you will export your Visio process so it can be loaded by SharePoint Designer. Once it is loaded, it can be used as a starting point for the completed Timesheet Approval process. 1. Save the Visio process drawing a. Click the Save button on the Quick Access Toolbar

b. Set the folder to C:\Office2010DeveloperTrainingKit\Labs\ClientWorkflow\Source\[language]\Start er c. Set the File name to Timesheet Approval.vsd and click Save 2. Export the process to SharePoint Designer a. Click the Export button in the Process ribbon tab b. Set the folder to C:\Office2010DeveloperTrainingKit\Labs\ClientWorkflow\Source\[language]\Start er c. Set the File name to Timesheet Approval.vwi and click Save 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 a. Using Internet Explorer navigate to http://intranet.contoso.com/sites/clientworkflow b. Click Site Actions -> Site Settings c. On the Site Settings page, click the Site collection features link d. Activate the SharePoint Server Enterprise Site Collection features feature Figure 8 Activated Site Collection Feature e. Navigate back to the Site Settings page using Site Actions -> Site Settings

f. Click the Manage site features link g. Activate the SharePoint Server Enterprise Site features feature Figure 9 Activated Site Feature h. Click Site Actions -> Edit Site in SharePoint Designer Figure 10 Edit in SharePoint Designer AdAdministrat 2. Create a new workflow imported from Visio a. Switch to the Workflows view using the Navigation bar on the left b. Click the Import from Visio button in the Workflows ribbon tab c. Browse to the Timesheet Approval.vwi file in the C:\Office2010DeveloperTrainingKit\Labs\ClientWorkflow\Source\[language]\Start er folder d. Click Next to move to the next page of the wizard e. Select the Reusable Workflow radio button f. Choose Timesheet in the content type drop down list

Figure 11 Import Workflow Dialog g. 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 a. In the If statement under Check for Overtime, click the field link b. Choose Overtime Hours in the field drop down list c. Click the equals link and set it to is greater than d. Click value and enter 0

Figure 13 Check if overtime approved 2. Initialize Send to Manager for Approval task a. In the action under Send to Manager for Approval click the this item link b. In the Choose List Item dialog, select Current Item and click OK 3. Define a custom Title to the approval message the manager receives a. Click the these users link b. Enter CONTOSO\Administrator in the Participants text box c. Click the button by the Title text box d. Enter the text Overtime approval for into the text box e. Click the Add or Change Lookup button f. Select Employees in the Data source drop down list g. Select Full Name in the Field from source drop down list h. Select ID in the Field drop down list Figure 14 Lookup Employee Full Name i. Click the fx button by the Value text box j. In the dialog, choose Employee in the Field from source k. Choose Lookup Id (as integer) in the Return field as drop down list

Figure 15 Choose Employee ID l. Click both OK buttons to return to the Select Task Process Participants dialog Figure 16 Completed Approval subject 4. Define a custom message for the approval sent to the manager a. Place the cursor into the Instructions text box b. Click the Add or Change Lookup button c. Choose Overtime Hours in the Field from source drop down list d. Click OK to close the dialog e. Add the following text after the lookup hours of overtime need approval f. Click OK to complete the approval message definition

Figure 17 Completed Approval Definition 5. Update the Approval process to set an OvertimeApproved variable indicating the result a. Click the Local Variables button on the Workflow ribbon tab b. Click the Add button to add a new variable c. Set the Name to OvertimeApproved and the Type to Boolean Figure 18 Add Overtime Approved Variable d. Click OK to create the new variable and click OK again to close the variables dialog e. Click the Approval Process link in the Send to Manager for Approval action f. Click the Change the behavior of a single task in the Customization section g. Locate the When a Task Completes section

h. Place the cursor after the first Log action and type Set Workflow Variable and press Enter Figure 19 On Task Completes Actions i. Click the workflow variable link and choose Variable: OvertimeApproved j. Click the value link and choose Yes k. Repeat this process following the second Log action and set the variable to No Figure 20 Overtime Approved Variable Set 6. Check the result of the approval and clear overtime hours if they were not approved a. Navigate back to the primary workflow by clicking the Editor link in the header of the window Figure 21

Navigation to Workflow Editor b. In the Check for Approval If statement, click the first value link c. Click the fx button d. Set Data source to Workflow Variables and Parameters e. Set Fields from source to Variable: OvertimeApproved Figure 22 Lookup Overtime Approved Variable f. Click OK to close the dialog g. Click the this test link and choose equals h. Click value and choose Yes Figure 23 Check if approval is complete i. Click the field link in the Clear Overtime Set action and choose Overtime Hours j. Click the value link and set it to 0 Figure 24 Clear overtime hours

7. Set the workflow s state to processed indicating the process is completed a. Place the cursor after the Check for Overtime if statement and type Set workflow status and press enter b. Click the Canceled link and type Processed Figure 25 Set workflow status 8. Change the workflow settings to show the Visio document in the status page and publish it to SharePoint a. Click the Workflow Settings link on the Workflow ribbon tab b. Check the Show workflow visualization on status page checkbox c. Click the Publish button on the Workflow Settings ribbon tab d. Once the publish is complete, click Association to Content Type in the Workflow Settings ribbon tab and choose Timesheet e. 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

a. In Internet Explorer navigate to http://intranet.contoso.com/sites/clientworkflow b. Click the Timesheets link in the navigation menu 2. Create a new timesheet entry with less than 0 overtime hours a. Click the New Item in the Items ribbon tab b. Create a new item with the following items i. Title Amy Alberts Timesheet ii. Employee Amy Alberts iii. Monday thru Friday Hours 8 iv. Total Hours 40 v. Overtime Hours 0 c. Select the new item in the list and click the Workflows button in its drop down menu d. In the Workflow page, click Timesheet Approval e. In the initiation page, click Start to start the workflow f. 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 a. Click the New Item in the Items ribbon tab b. Create a new item with the following items

i. Title Alan Brewer Timesheet ii. Employee Alan Brewer iii. Monday thru Thursday Hours 8 iv. Friday Hours - 9 v. Total Hours 40 vi. Overtime Hours 1 c. Select the new item in the list and click the Workflows button in its drop down menu d. In the Workflow page, click Timesheet Approval e. In the initiation page, click Start to start the workflow f. Click the In Progress link to view the status Figure 27 Awaiting Overtime Approval g. Click Edit Item in the Task s drop down menu h. In the task form, click the Reject button

Figure 28 Approve Overtime Task i. When the task completes, navigate to the Timesheets list and verify the entry has no overtime hours Figure 29 Overtime Hours Cleared Exercise 3: Building a Workflow in Visual Studio 2010 In this exercise you will use Visual Studio to create a workflow that will use the timesheet data approved in the previous examples and convert it to a Word document. The generated timesheet document will be stored in a new document library that can be chosen when the workflow was associated. Task 1 Create a new Visual Studio 2010 Sequential Workflow In this first task, you will create the sequential workflow item that will be the starting point for the timesheet generation workflow. 1. Add a new Sequential Workflow item to the TimesheetApplication starter project

a. Open Visual Studio 2010 and open the starter lab at C:\Office2010DeveloperTrainingKit\Labs\ClientWorkflow\Source\[language]\Start er\timesheetapplication\timesheetapplication.sln b. Locate the Solution Explorer and see the SharePoint items already existing in the solution Figure 29(a) Figure 29(b) TimesheetApplication Solution Note: Visual Studio 2010 allows the creation and management of SharePoint items, features, and solutions in Visual Studio and deployment with a single menu option

c. Right click TimesheetApplication in the Solution Explorer and select Add -> New Item d. In the Add New Item dialog, select the Visual C#\Visual Basic -> SharePoint -> 2010 template category and choose the Sequential Workflow item e. Set the name to TimesheetGeneration and click Add to create the new workflow item Figure 30(a) Figure 30(b) Add New Sequential Workflow

2. Using the SharePoint Customization Wizard, configure the site used for debugging a. In the first page of the SharePoint Customization Wizard set the name to Timesheet Generation b. Verify the List Workflow radio button is selected and click Next Figure 31 Set Workflow Name c. Verify the check box indicating a workflow association should be created on deployment is cleared and click Finish

Figure 32 Set Workflow Association Options Note: An association will be created manually to test the Association page Task 2 Create the custom Association page In this task, you will create a custom Association page that allows the user associating the workflow to the Timesheet list to choose a document library to store the generated timesheet. 1. Add a new Association Form to the TimesheetGeneration workflow a. Right click TimesheetGeneration SharePoint item in the Solution Explorer and click Add -> New Item b. In the Add New Item dialog, select the Visual C#\Visual Basic -> SharePoint -> 2010 template category and choose the Workflow Association Form item c. Set the name to AssociationForm and click Add to create the form

Figure 33 Add New Association Form d. Verify that the new AssociationForm.aspx file exists inside the TimesheetGeneration SharePoint item Figure 34(a) Figure 34(b) Workflow SharePoint Item 2. Define the layout of the page using custom ASPX markup a. Open the AssociationForm.aspx page s markup by right clicking it in the Solution Explorer and selecting View Markup b. Locate the asp:content node with an ID of Main

c. Place the following markup inside the asp:content node to define a UI with a drop down list containing all document libraries in the current site ASPX i. Make sure the table is placed above the existing buttons <table> <tr> <td>archive Document Library</td> <td> <asp:dropdownlist ID="ArchiveLibrary" runat="server" /> </td> </tr> </table> 3. Implement the code behind that will populate and extract information from the ASPX page a. Open the page s code by right clicking it in the Solution Explorer and selecting View Code b. Add the follow code to the Page_Load method to check if this is the first load of the form C# protected void Page_Load(object sender, EventArgs e) { bool initialload = false; if (ViewState["associationParams"] == null) initialload = true; InitializeParams(); Visual Basic Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Dim initialload As Boolean = False If ViewState("associationParams") Is Nothing Then initialload = True End If InitializeParams() Note: Since the Association form s initial load is a postback, a special viewstate parameter is used to determine if this is the initial load. c. Add the following code to Page_Load to load the DropDownList with all document libraries in the current site

C# InitializeParams(); // Optionally, add code here to pre-populate your form fields. if (initialload) { SPListCollection documentlibraries = Web.GetListsOfType(SPBaseType.DocumentLibrary); foreach (SPList documentlibrary in documentlibraries) ArchiveLibrary.Items.Add(documentLibrary.Title); Visual Basic InitializeParams() ' Optionally, add code here to pre-populate your form fields. If initialload Then Dim documentlibraries As SPListCollection = Web.GetListsOfType(SPBaseType.DocumentLibrary) For Each documentlibrary As SPList In documentlibraries ArchiveLibrary.Items.Add(documentLibrary.Title) Next documentlibrary d. Following the load of the drop down list, add the code to select the current archive document library C# if (associationparams.associationguid!= Guid.Empty) { SPList list = Web.Lists[associationParams.TargetListGuid]; SPWorkflowAssociation association = list.workflowassociations[associationparams.associationguid]; ArchiveLibrary.SelectedValue = association.associationdata; } } Visual Basic If associationparams.associationguid <> Guid.Empty Then Dim list As SPList = Web.Lists(associationParams.TargetListGuid) Dim association As SPWorkflowAssociation = list.workflowassociations(associationparams.associationguid) ArchiveLibrary.SelectedValue = association.associationdata End If }

e. Add the following code to GetAssociationData to retrieve the name of the currently selected item C# private string GetAssociationData() { return ArchiveLibrary.SelectedValue; } Visual Basic Private Function GetAssociationData() As String Return ArchiveLibrary.SelectedValue End Function Task 3 Implement the TimeSheet generation workflow In this task, you will implement the workflow process and add the custom activities to generate and store the timesheet. 1. Add a new Code activity to the workflow that will generate the timesheet document a. Open the workflow in the designer by right clicking TimesheetGeneration.cs(TimesheetGeneration.vb in case of VB) in the Solution Explorer and choosing View Designer b. Locate the Code activity in the Windows Workflow v3.0 section of the Toolbox and drag it onto the workflow following the existing application c. Note: If the Toolbox is not visible, show it by clicking View -> Toolbox Figure 35 New Code Activity d. Select the new code activity, right click it and select Properties e. In the Properties window, set the (Name) property to GenerateDocument

Figure 36 Code Activity Properties 2. Add the code behind to create and store the new timesheet document a. Open the code behind for the GenerateDocument activity by double clicking it b. In the new GenerateDocument_ExecuteCode method, add the following code to generate the timesheet C# private void GenerateDocument_ExecuteCode(object sender, EventArgs e) { Timesheet timesheet = new Timesheet(workflowProperties.Item); Visual Basic Private Sub GenerateDocument_ExecuteCode(ByVal sender As Object, ByVal e As EventArgs) Dim timesheet_renamed As New Timesheet(workflowProperties.Item) c. Following the previous code, add the following code to lookup the archive document library and write the timesheet into it. C# } SPDocumentLibrary archivelibrary = workflowproperties.web.lists[ workflowproperties.associationdata] as SPDocumentLibrary; archivelibrary.rootfolder.files.add( workflowproperties.item.title + ".docx", timesheet.writetimesheet()); Visual Basic Dim archivelibrary As SPDocumentLibrary = TryCast(workflowProperties.Web.Lists(workflowProperties.AssociationData), SPDocumentLibrary)

archivelibrary.rootfolder.files.add(workflowproperties.item.title & ".docx", timesheet.writetimesheet()) } Note: The workflowproperties.associationdata property is initialized by the OnWorkflowInitialized activity. The value is stored in the SPWorkflowAssociation object based on the association data stored in the Association form. 3. Deploy the solution by right clicking TimesheetApplication in the Solution Explorer and clicking Deploy Exercise 3 Verification In order to verify that you have correctly performed all steps of exercise 3, proceed as follows: Test the Workflow Execute your workflow and verify it converts the timesheet list item into a new document in the selected document library. 1. Associate the new Timesheet Generation workflow with the Timesheets a. In Internet Explorer, navigate to http://intranet.contoso.com/sites/clientworkflow/lists/timesheets b. In the List ribbon tab, click Workflow Settings -> Add a Workflow c. In the Workflow list, select Timesheet Generation and enter a name of Timesheet Generation Figure 37 Workflow Association Form d. Click Next to move to the custom association form. e. In the custom association form, select Timesheet Archive in the drop down list and click Association Workflow to complete the association

Figure 38 Custom Association Form 2. Execute the new workflow to generate a new Timesheet Word document a. In Internet Explorer, navigate to http://intranet.contoso.com/sites/clientworkflow/lists/timesheets b. Select a timesheet in the list and click the Workflows button in its drop down menu Figure 39 Item Menu c. In the Workflow page, click Timesheet Generation to start the process d. When the workflow is completed navigate to http://intranet.contoso.com/sites/clientworkflow/ TimesheetArchive and verify a new timesheet document has been created Figure 40 Timesheet Archive Document Library e. Click the document s drop down menu to open the document in Word and verify it contains the timesheet data

Summary Figure 41 Generated Timesheet Document In this exercise you learned how to automate your business processes using the workflow offerings in SharePoint 2010. First, Visio 2010 was used to define the rough outline for a business process which was exported to SharePoint Designer 2010 for completion. The action based interface of SharePoint Designer 2010 allowed for simple creation of a process that could be completed by a IT Professional. Once the first process was in place, a more complex process which included custom code was created using Visual Studio 2010 and the SharePoint workflow tools.

Appendix No Items No Appendix content