Overview and Demonstration of declarative workflows in SharePoint using Microsoft SharePoint Designer 2007 Kevin Hughes MCT, MCITP, MCSA, MCTS, MCP, Network+, A+, ITIL SharePoint Architect Kevin@SharePointKevin.com http://www.sharepointkevin.com A SharePoint workflow is the automated movement of documents or items through a sequence of actions or tasks that are related to a business process Enables the organization to attach business logic to documents or items in a SharePoint list or library. Can streamline the cost and time required to coordinate common business processes When you buy an item, you need to: find correct item take item to counter receive the price from attendant decide between credit card or cash ▪ if cash: ▪ ▪ ▪ ▪ give appropriate amount to attendant receive any change verify change pocket change ▪ if credit card: ▪ ▪ ▪ ▪ ▪ ▪ give credit card to attendant receive receipt for signature verify amount sign receipt return receipt to attendant put pen in pocket retrieve item, and run before the attendant notices the missing pen Allow automation of many business processes Can work with many SharePoint components OOTB workflows have limitations Conditional logic is NOT supported Can not look up site data Little ability to route tasks Declarative means Follows a pre-defined process model where all specifications, conditions and actions are defined within the workflow. Relies on known and predictable circumstances The websvcWebPartPages Web Service in Windows SharePoint Services contains methods that enable a declarative rules-based, code-free workflow editor, such as Office SharePoint Designer 2007, to create workflow templates and associate them with specific SharePoint lists. Defined entirely in Extensible Application Markup Language (XAML) For a given site, declarative workflows must be stored in a site-level document library called Workflows. Files: Workflow markup (.xoml) file Rules file Workflow configuration file Any .aspx forms needed, such as initiation forms (for workflows that are started manually) or custom task forms The files for each declarative workflow must be stored in a separate folder in the Workflow document library. Write workflow logic more advanced than OOTB templates Create rules that associate conditions and actions with items in SharePoint lists and libraries Use conditions to allow branching workflow paths Manipulate list items or list data Automatically generates necessary, customizable, forms No-Code required Security Context – Always run in the context of the user account which “owns” the workflow. Can NOT be defined for Content Types Must be attached to specific list/library Can NOT be triggered by “System Account” Can NOT be triggered by list items submitted via Email Fixed in SP2 to allow STSADM command to set this property “stsadm.exe –o setproperty –propertyname declarativeworkflowautostartonemailenabled – propertyvalue yes” Uses “default” Task list – may not be the one you think Events Conditions Actions What starts or initiates a workflow An item is created. An item is changed. A workflow participant clicks a start button on the SharePoint site. Rules that apply conditional logic to SharePoint lists and items Rules establish a condition where the workflow performs the associated action only if that condition is true Associated with one or more actions: If all clauses in the condition are true, do all the associated actions SPD 2007 provides several ready-made, reusable conditions Is created or modified in a specific time span. Is created or modified by a specific person. Has a title field that contains specified keywords. Is a file of a specific type or has a file size in a specific range. (Available only when the workflow is attached to a document library.) Most basic unit of work in a workflow SPD 2007 provides a set of ready-made, reusable actions Create, copy, change, or delete list items (including documents). Check items in or out. Send an e-mail message. Create a task for someone on the Tasks list of your team site. Collect data from a participant that can be referenced later in the workflow. Pause or stop the workflow. Log workflow information to a History list to use for repudiation or workflow debugging. Set workflow variables or perform calculations. Workflows may contain any number of actions Not all actions in a workflow may be automated An action does not require a condition Actions can be set up to run at the same time (parallel) or one after another (serial) Parallel – All actions “fire” at the same time Serial – One action must complete before the next one begins In any given rule (conditions and actions), all actions must be either serial or parallel A set of serial or parallel actions must be contained within a single step A workflow is comprised of one or more steps Each step can contain any number of actions and associated conditions Steps allow you to group conditions and actions so that one set of rules (conditions and actions) can be evaluated and performed before a second set Rules in one step are processed to conclusion before going on to the next step Each step can hold one set of 'Else If' conditional branches Make workflow more dynamic and flexible Collect information from workflow participants at predefined times in the workflow Make it possible for participants to interact with the tasks for that workflow Two types of workflow forms Initiation Form Custom Task Form SPD 2007 automatically generates the ASP.NET forms, you can customize them. Workflow forms are ASP.NET pages with a Data Form Web Part and a master page applied to it. The .aspx files are stored on the SharePoint site with the workflow source files. You can open and customize these forms as you would any other .aspx file Gathers information from the workflow participant when they start the workflow Displayed to users when they manually start a workflow on a given SharePoint item Users can specify additional parameters or information about the workflow as it applies to the given SharePoint item Allows workflow participants to interact with tasks in the Tasks list on a SharePoint site Custom Task Wizard - create custom form fields and add them to a custom task form Make any necessary changes or customizations to your site, list, or library A workflow is always attached to exactly one SharePoint list or library Site must have at least one list or library before you create a workflow Must create custom columns or settings before you create the workflow so that those columns and settings are available to you in the Workflow Designer Turn on desired features before you design the workflow Same version of the Workflow Foundation must be installed on both your computer and the server SharePoint Designer Workflows http://www.sharepointkevin.com/wfdemo/Lists/Active%20Projects/AllItems.aspx Infinite Loops – BAD! A workflow that starts when an item is changed should never change an item in the list to which it is attached A workflow that starts when an item is created should never create an item in the list to which it is attached Recursive firing is possible No data in the list item is changed until the workflow is complete