Office 2010 Workflow: Developing Collaborative Solutions ■ ■ ■ MARK J. COLLINS www.it-ebooks.info Office 2010 Workflow: Developing Collaborative Solutions Copyright © 2010 by Mark J. Collins All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-4302-2904-9 ISBN-13 (electronic): 978-1-4302-2905-6 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. President and Publisher: Paul Manning Lead Editor: Jonathan Hassell Technical Reviewers: Robert Garrett and Michael Mayberry Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Duncan Parkes, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Coordinating Editor: Anne Collett Copy Editor: Kim Wimpsett Compositor: Kimberly Burton Indexer: Potomac Indexing, LLC Artist: April Milne Cover Designer: Anna Ishchenko Distributed to the book trade worldwide by Springer Science+Business Media, LLC., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. For information on translations, please e-mail [email protected], or visit www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/info/bulksales. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at www.apress.com. You will need to answer questions pertaining to this book in order to successfully download the code. ii www.it-ebooks.info Contents at a Glance ■Preface..........................................................................................................................................................xix ■About the Author...........................................................................................................................................xxi ■About the Technical Reviewers....................................................................................................................xxii ■Acknowledgements.....................................................................................................................................xxiii ■Introduction.................................................................................................................................................xxiv ■PART 1: Introduction........................................................................................................................................1 ■Chapter 1: Overview of Microsoft Office..........................................................................................................3 ■Chapter 2: Setting Up a Development Environment.......................................................................................11 ■Chapter 3: SharePoint Primer........................................................................................................................45 ■PART 2: Using Workflows...............................................................................................................................57 ■Chapter 4: Three-state Workflow...................................................................................................................59 ■Chapter 5: Office Applications as Workflow Participants..............................................................................77 ■Chapter 6: Creating Workflows with SharePoint Designer...........................................................................97 ■Chapter 7: Creating Reusable and Site Workflows.......................................................................................119 ■PART 3: Workflows in Visual Studio 2010....................................................................................................155 ■Chapter 8: Creating a Simple Site Workflow................................................................................................157 ■Chapter 9: Exploring the SharePoint Object Model......................................................................................181 ■Chapter 10: Custom Workflow Forms..........................................................................................................199 ■Chapter 11: Handling Events........................................................................................................................241 ■Chapter 12: LINQ to SharePoint....................................................................................................................275 ■Chapter 13: Using State Machine Workflows...............................................................................................301 ■PART 4: Miscellaneous Topics......................................................................................................................383 ■Chapter 14: Using a ConditionedActivityGroup............................................................................................385 ■Chapter 15: Importing Reusable Workflows................................................................................................405 ■Chapter 16: Creating Custom Actions..........................................................................................................425 ■Chapter 17: Pluggable Workflow Services...................................................................................................451 ■PART 5: Business Connectivity Services (BCS)............................................................................................473 ■Chapter 18: Creating External Content Types..............................................................................................475 ■Chapter 19: Implementing a .NET Assembly Connector...............................................................................509 ■Chapter 20: Using External Lists in Outlook.................................................................................................553 ■Index.............................................................................................................................................................573 iv www.it-ebooks.info Contents ■Preface.....................................................................................................................xix ■About the Author......................................................................................................xxi ■About the Technical Reviewers...............................................................................xxii ■Acknowledgements................................................................................................xxiii ■Introduction............................................................................................................xxiv ■PART 1: Introduction ...................................................................................................1 ■Chapter 1: Overview of Microsoft Office......................................................................3 End-User Perspective........................................................................................................3 Office Overview........................................................................................................................................3 Workflows in SharePoint..........................................................................................................................4 Workflow Overview............................................................................................................5 Code-less Workflows................................................................................................................................6 Visual Studio Workflows...........................................................................................................................6 Business Connectivity Services.........................................................................................6 Technology Overview.........................................................................................................7 Software Products....................................................................................................................................7 Client-Server Topology.............................................................................................................................9 Summary.........................................................................................................................10 ■Chapter 2: Setting Up a Development Environment...................................................11 Single-Computer Installation...........................................................................................11 Initial Setup............................................................................................................................................11 SQL Server..............................................................................................................................................12 v www.it-ebooks.info ■ CONTENTS Active Directory......................................................................................................................................12 Installing SharePoint on a Server OS...............................................................................12 Installing the Prerequisites.....................................................................................................................13 Installing SharePoint Server...................................................................................................................14 Running the SharePoint Products Configuration Wizard........................................................................16 Using the Central Administration Web Application.................................................................................22 Installing SharePoint on a Desktop..................................................................................26 Installing the Prerequisites.....................................................................................................................28 Enabling Windows Features...................................................................................................................30 Installing SharePoint Server............................................................................................32 Installing Hotfix KB970315.....................................................................................................................34 Running the Configuration Wizard..........................................................................................................35 Initial Site Configuration.........................................................................................................................37 Installing Other Applications............................................................................................39 Installing Visual Studio 2010..................................................................................................................39 Office Client Applications.......................................................................................................................39 SharePoint Designer 2010......................................................................................................................40 Installing Office 2010..............................................................................................................................41 Installing Visio 2010...............................................................................................................................41 Configuring E-mail...........................................................................................................42 Providing an E-mail System...................................................................................................................42 Configuring SMTP...................................................................................................................................42 Summary.........................................................................................................................43 ■Chapter 3: SharePoint Primer....................................................................................45 Columns...........................................................................................................................45 Text Columns..........................................................................................................................................46 Date & Time Columns.............................................................................................................................47 Person or Group Columns.......................................................................................................................47 vi www.it-ebooks.info ■ CONTENTS Choice Columns......................................................................................................................................48 Lookup Columns.....................................................................................................................................49 Calculated Columns................................................................................................................................50 Site Columns Collection..........................................................................................................................50 Content Types..................................................................................................................51 Lists and Libraries...........................................................................................................51 Supporting Content Types......................................................................................................................52 Views......................................................................................................................................................52 Subsites...........................................................................................................................53 Templates........................................................................................................................54 Site Templates........................................................................................................................................54 List Templates........................................................................................................................................55 Summary.........................................................................................................................56 ■PART 2: Using Workflows..........................................................................................57 ■Chapter 4: Three-state Workflow..............................................................................59 Creating a New Site.........................................................................................................59 Creating a New List................................................................................................................................61 Understanding the Workflow Process....................................................................................................62 Defining the List Columns.......................................................................................................................63 Associating the Workflow................................................................................................65 Defining the First Transition...................................................................................................................68 Defining the Second Transition..............................................................................................................69 Using the Work Request Workflow..................................................................................70 Workflow Tasks...............................................................................................................74 Summary.........................................................................................................................76 ■Chapter 5: Office Applications as Workflow Participants..........................................77 Creating a SharePoint Site...............................................................................................77 vii www.it-ebooks.info ■ CONTENTS Creating a Document Library..................................................................................................................78 Associating a Workflow..........................................................................................................................79 Using the Document Workflow........................................................................................82 Submitting a New Design Document......................................................................................................82 Enabling Office.......................................................................................................................................84 Receiving Workflow E-mail Notifications...............................................................................................84 Receiving a Task Notification.................................................................................................................86 Using Office Shortcuts............................................................................................................................87 Integrating the Task List..................................................................................................89 Executing the Workflow Again................................................................................................................91 Displaying the Task in Outlook...............................................................................................................91 More About Tasks............................................................................................................92 Working with Multiple Task List.............................................................................................................92 Deleting Tasks........................................................................................................................................94 Summary.........................................................................................................................95 ■Chapter 6: Creating Workflows with SharePoint Designer.......................................97 Creating the Site..............................................................................................................97 Creating a Custom List...........................................................................................................................98 Defining the List Columns.......................................................................................................................98 Using Visio to Define a Workflow...................................................................................100 Designing a Workflow in Visio..............................................................................................................100 Exporting a Visio Workflow...................................................................................................................101 Importing a Visio Workflow............................................................................................102 Entering the Workflow Definition..........................................................................................................103 Specifying a Condition..........................................................................................................................105 Creating a Calendar Entry.....................................................................................................................107 Adding Workflow Details......................................................................................................................110 Configuring the Workflow.....................................................................................................................112 viii www.it-ebooks.info ■ CONTENTS Executing the Workflow.................................................................................................114 Exporting to Visio...........................................................................................................117 Summary.......................................................................................................................118 ■Chapter 7: Creating Reusable and Site Workflows..................................................119 Reusable Workflows......................................................................................................119 Creating a New Site..............................................................................................................................119 Creating a Reusable Workflow.............................................................................................................122 Workflow Editor Overview....................................................................................................................123 Initiation Form Parameters...................................................................................................................126 Entering the Workflow Definition..........................................................................................................129 Checking the Review Outcome.............................................................................................................133 Adding a Second Step..........................................................................................................................135 Publishing the Workflow.......................................................................................................................140 Associating the Workflow.....................................................................................................................140 Testing the Workflow............................................................................................................................142 Site Workflows...............................................................................................................144 Initiation Form Parameters...................................................................................................................145 Designing the Workflow.......................................................................................................................147 Testing the Workflow............................................................................................................................150 Summary.......................................................................................................................153 ■PART 3: Workflows in Visual Studio 2010...............................................................155 ■Chapter 8: Creating a Simple Site Workflow...........................................................157 Using Visual Studio 2010...............................................................................................158 Creating a SharePoint Project...............................................................................................................158 Running as Administrator.....................................................................................................................159 Configuring the SharePoint Project......................................................................................................161 SharePoint Support in Visual Studio 2010............................................................................................164 Designing a SharePoint Workflow.................................................................................168 ix www.it-ebooks.info ■ CONTENTS Logging to the History List....................................................................................................................168 Creating a New Task............................................................................................................................168 Defining the Activity’s Properties.........................................................................................................168 Entering Code in the Code-Beside Class..............................................................................................171 Deploying the Workflow.................................................................................................171 Running the Workflow..........................................................................................................................174 Visual Studio Cleanup...........................................................................................................................176 Resolving Retract Issues................................................................................................176 SharePoint Deployment Configuration..................................................................................................177 Selecting the Active Configuration.......................................................................................................178 Summary.......................................................................................................................179 ■Chapter 9: Exploring the SharePoint Object Model.................................................181 Creating a SharePoint Project in Visual Studio..............................................................181 Adding a Workflow...............................................................................................................................183 SharePoint Customization Wizard........................................................................................................184 Writing SharePoint Details to the History List................................................................185 Creating the Workflow Design..............................................................................................................186 Accessing the Object Model.................................................................................................................188 Testing the Workflow............................................................................................................................192 Scanning the Tasks List.................................................................................................193 Adding an Activity to Check the Tasks List...........................................................................................193 Implementing Check Tasks Logic.........................................................................................................193 Testing the Workflow............................................................................................................................196 More About Content Types.............................................................................................197 Summary.......................................................................................................................198 ■Chapter 10: Custom Workflow Forms......................................................................199 Creating a Sequential Workflow....................................................................................199 Adding an Initiation Form...............................................................................................200 x www.it-ebooks.info ■ CONTENTS Customizing the Initiation Form............................................................................................................203 Getting the Initiation Data in the Workflow...........................................................................................205 Implementing the Workflow...........................................................................................206 Replicator Activity.................................................................................................................................207 Setting Up the Replicator Activity.........................................................................................................208 CreateTask Activity...............................................................................................................................209 Testing the Workflow............................................................................................................................212 Content Types................................................................................................................214 Creating a Content Type.......................................................................................................................214 Content Type Inheritance......................................................................................................................217 Adding Field Definitions........................................................................................................................217 Adding the Field References.................................................................................................................218 Using the New Content Type................................................................................................................222 Testing the Workflow............................................................................................................................225 Creating Custom Task Forms with InfoPath 2010..........................................................226 Connecting to SharePoint.....................................................................................................................226 Modifying the Form Layout...................................................................................................................230 Defining Rules......................................................................................................................................233 Publishing the Form..............................................................................................................................235 Testing the Custom Form.....................................................................................................................236 Summary.......................................................................................................................239 ■Chapter 11: Handling Events...................................................................................241 Modifying the Calendar List...........................................................................................241 Adding the MenuUrl Column.................................................................................................................241 Adding the Attendees Column..............................................................................................................242 Creating a New Event...........................................................................................................................244 Designing the Workflow.................................................................................................246 Creating the Workflow Project..............................................................................................................246 xi www.it-ebooks.info