Building a Workflow by Using SharePoint Designer 2007


A custom workflow that is created using SharePoint Designer 2007 can be started in various ways: automatically after a file is created, automatically after a file is changed, or manually. Within workflows, you can use actions that are available out of the box, such as assigning a task to someone or sending an e-mail.

Note 

Take some time to think about how the workflow should look before you grab SharePoint Designer 2007. Make sure you have, at the least, a clear picture of the workflow in your mind before you start creating one. Or better yet, create some kind of diagram to represent the workflow. Microsoft Office Visio is a suitable tool to create workflow diagrams.

The whole procedure of building a workflow with SharePoint Designer 2007 can be divided into four steps:

  1. Create a workflow.

  2. Customize the workflow initiation settings.

  3. Configure the predefined conditions and activities.

  4. Generate the workflow definition template and deployment.

In addition, the workflow designer should understand how SharePoint Designer 2007 controls custom activities but allows the extension of built-in workflows. Each of these topics is discussed in this section.

Creating a Workflow

To create a new workflow with SharePoint Designer 2007, complete the following steps:

  1. Open the SharePoint site where you want to create a workflow using SharePoint Designer 2007.

  2. Open the Workflow Designer Wizard by using one of the flowing methods:

    1. On the File menu, point to New and then select Workflow.

    2. On the File menu, select New.

      This will start the New dialog box, shown in Figure 28-2. Click on the SharePoint Content tab, and choose Workflow. Click Blank Workflow to create a new workflow.

  3. On the Workflow Designer page shown in Figure 28-3, give the workflow a descriptive name and attach the workflow to a list that is available on your SharePoint site. A drop-down list shows all lists located on your SharePoint site.

    You can also select one or more of the following workflow start options for items in the list you have chosen:

    1. Allow This Workflow To Be Manually Started From An Item

    2. Automatically Start This Workflow When A New Item Is Created

    3. Automatically Start This Workflow Whenever An Item Is Changed

  4. Click Next. This takes you to the configuration of the workflow steps, including the conditions and activities.

image from book
Figure 28-2: SharePoint Content tab in the New dialog box

image from book
Figure 28-3: Defining your new workflow

Customizing the Workflow Initiation Settings

A workflow uses initiation forms that are displayed to users as soon as they start a workflow that is associated with a given SharePoint item. You can use initiation forms to let users override or append the association parameters set by administrators, or specify additional parameters or information about the workflow as it applies to the given SharePoint item. Not all workflows require the use of initiation forms. You can create an initiation stage for your workflow in SharePoint Designer 2007. If you do, SharePoint Designer 2007 automatically generates an initiation form, using ASP.NET, according to your initiation specifications.

To create an initiation form according to your initiation specifications, complete the following steps:

  1. Click the Initiation button at the bottom of the Workflow Designer Wizard. This opens the Workflow Parameters dialog box. (See Figure 28-4.)

  2. Click Add to add workflow parameters. This opens the Add Field dialog box shown in Figure 28-5.

  3. The Add Field dialog box gives you the chance to add a field to specify a workflow parameter and choose an information type for that field. There is a range of types you can choose from. Depending on which type you choose, other contextual values will need to be defined. For example, if you create a new field called DateFinished and select the information type Date And Time, and click Next, a new window appears that shows you a range of options specifically concerned with date and time, as shown in Figure 28-6.

image from book
Figure 28-4: Workflow Parameters dialog box

image from book
Figure 28-5: Add Field dialog box

image from book
Figure 28-6: Defining date and time information type for a field

SharePoint Designer 2007 generates all ASP.NET forms that are required for workflow initiation. These .aspx files are stored on the SharePoint site, together with the workflow source files. They can be opened and customized in the same way as you would for any other .ASPX Web Form.

Configuring the Predefined Conditions and Activities

The next step of the workflow build process is to define the workflow steps. There is no practical limit to the number of workflow steps that can be added to a workflow; you can add as many as you want. You can add a workflow step by clicking on the Add Workflow Step link at the right of the wizard page under the heading Workflow Steps (see also Figure 28-15 later in this chapter). This Workflow Designer Wizard page lets you select conditions and activities.

Note 

Be sure to give the workflow step a descriptive name. This makes it easier to adjust the workflow once it is created.

Conditions

Conditions are configurable conditional clauses that direct the flow of the workflow. Conditions are represented by a sentence that contains variables that can be configured by the workflow designer using drop-down menus and dialog boxes. You can select conditions from a predetermined list and configure those conditions using the SharePoint Designer 2007 interface.

In SharePoint Designer 2007, you have nine standard conditions to choose from. The following list provides an overview of all available conditions:

  • Custom Condition: field equals value. The field and value variables are variables that can be configured by you. For example, if you previously selected that the workflow applies to a document library, clicking field results in the display of a drop-down list containing all column names of that document library. Values in custom conditions are context-dependent. For example, you can choose a document library column that has the drop-down list data type. Once you click the value variable of a custom condition, a drop-down list is displayed that contains the values of the document library drop-down list column.

  • Title Field Contains Keywords: title field contains keywords. The only part of a Title Field Contains Keywords condition that you can configure is the keywords variable. This variable is a text box that lets you type the keywords that you want to use. If you are unsure which keywords you are looking for, you can click the Display Data-Binding button next to the Keywords item to display the Define Workflow Lookup dialog box shown in Figure 28-7. This dialog box gives you the chance to select a list or library from a SharePoint site and look up which values it contains.

  • Modified In A Specific Date Span: modified between date and date. This condition lets you define two date variables. If you click one of the date variables, you can use the Date Value dialog box to choose a value. This dialog box is shown in Figure 28-8.

  • Modified By A Specific Person: modified by specific person. The specific person variable lets you configure a specific person via the Select Users dialog box shown in Figure 28-9.

  • Created In A Specific Date Span: created between date and date. This condition contains two date variables. You can specify values for the date variables via the Date Value dialog box (shown earlier in Figure 28-8).

  • Created By A Specific Person: created by a specific person. The value for the specific person variable can be configured via the Select Users dialog box (shown in Figure 28-9).

  • The File Type Is A Specific Type: the file type is specific type. You can configure the specific type variable by typing the file type extension you expect in the text box that appears.

  • The File Size In A Specific Range Kilobytes: the file size is between size and size kilobytes. The sizes variables are configurable via text boxes that will only let you type numerical values.

  • Advanced Condition: value equals value. You can configure the values variables via the Display Data-Binding button, which is located next to the Keywords item. This opens a Define Workflow Lookup dialog box, which was shown earlier in Figure 28-7.

image from book
Figure 28-7: Define Workflow Lookup dialog box

image from book
Figure 28-8: Date Value dialog box

image from book
Figure 28-9: Select Users dialog box

Activities

SharePoint Designer 2007 uses a wizard-driven interface that enables users to build sequential workflows that consist of predefined activities. Users can select activities from a predetermined list and configure those activities using the SharePoint Designer 2007 interface. These activities are essentially the same activities that are present in the Visual Studio 2005 Designer for Windows Workflow Foundation. There is a small difference, however, because SharePoint Designer 2007 hosts a user interface that is considerably more user friendly. In SharePoint Designer 2007, each activity appears in the form of an action, represented by a sentence that contains variables that the user can configure using drop-down menus and look-up dialog boxes. In Visual Studio 2005 Designer, you have to manipulate activities programmatically.

Core Actions

Out of the box, SharePoint Designer 2007 supports 17 different actions. Those actions can be divided into core actions, task actions, and list actions. The following list provides an overview of the core actions:

  • Send An Email: send this message. Clicking the this message variable displays the Define E-mail Message dialog box shown in Figure 28-10. This dialog box lets you compose a message and makes extensive use of lookup variables to facilitate this process.

  • Set Field In Current Item: set field to value. Clicking the field variable results in the display of a drop-down list containing all the columns that are available for the list or library. The value variable can be configured by typing a value into a text box or by clicking the Display Data Binding button to open the Define Workflow Lookup dialog box (shown earlier in Figure 28-7).

  • Wait For Field Change In Current Item: wait for field to equal value. Clicking the field variable displays a drop-down list containing all column names of the list or library that you have previously selected. The value variable is context-dependent. If the field variable you choose is a column that has the drop-down list data type, the values of this column are displayed as a drop-down list once you click the value variable.

  • Set Workflow Variable: set workflow variable to value. Clicking the workflow variable displays a drop-down list containing all variables that are custom made for this particular workflow. If there are no workflow variables made yet, you get the option to create a new variable. You can also create a workflow variable by clicking the Variables button at the bottom of the Workflow Designer Wizard. This opens the Workflow Local Variables dialog box shown in Figure 28-11.

  • Do Calculation: calculate value plus value, store in variable. Clicking the variable item displays a drop-down list containing all the workflow variables that you have made for this particular workflow. If there are no workflow variables present, you can create a new one by clicking the Variables button at the bottom of the Workflow Designer Wizard. This opens the Workflow Local Variables dialog box shown in Figure 28-11.

  • Stop Workflow: stop the workflow and log this message. The this message variable can be configured to define a helpful message explaining why the workflow has stopped. This message will be logged in the history list.

  • Log To History List: log this message to the workflow history list. You can define a message using the this message variable, which is logged in the workflow history list on the SharePoint site.

  • Set Moderation Status: set moderation status to this status with comments. Clicking the this status variable displays a drop-down list containing the following status values: approved, rejected, and pending. Clicking the comments variable displays a text box that enables you to define additional comments.

image from book
Figure 28-10: Define E-mail Message dialog box

image from book
Figure 28-11: Workflow Local Variables dialog box

Task Actions

The following list provides an overview of the three task actions that are available in SharePoint Designer 2007:

  • Collect Data From A User: collect data from this user, store task ID in 0. The data and this user variables can be configured by clicking them. If you click the data variable, the Custom Task Wizard dialog box opens, which offers you the chance to create a custom task for your workflow. SharePoint Designer 2007 automatically generates an ASP.NET form for such a task, according to the specifications defined in the wizard. Creating a task consists of giving the task a custom name, giving it a description, and defining fields (or questions) for the task. Please refer to the "Creating a Real World Workflow Example" section that demonstrates how to implement an example workflow. Each field is based on an information type (or data type). For example, you can create a drop-down list or a field that contains a single line of text. This option was shown earlier in Figure 28-5. Tasks are used to collect information from workflow users. The information will be stored in the Tasks list in the SharePoint site that contains the workflow. You can use custom task information later in the workflow by retrieving it via the Define Workflow Lookup dialog box.

    If you click the this user variable, you can select one person or more in the Select Users dialog box. (See Figure 28-9.) Each task has a unique task ID. By default, this is 0. Task IDs can be changed by assigning the value of a workflow variable to it. You can create a workflow variable by clicking the Variables button at the bottom of the Workflow Designer Wizard. This opens the Workflow Local Variables dialog box shown in Figure 28-11.

  • Assign A Todo Item: assign a todo item to these users. Clicking on the a todo item variable opens the Custom Task Wizard dialog box. This dialog box lets you define a todo item that will be added to the task list for each specified user. With the these users variable, you can select one or more users in the Select Users dialog box (shown earlier in Figure 28-9).

  • Assign A Group Survey: assign a custom survey to these users. Clicking the a custom survey variable opens the Custom Task Wizard dialog box. This dialog box lets you define a survey form for a group of users. With the these users variable, you can select one or more users in the Select Users dialog box (shown in Figure 28-9).

The following list provides an overview of the six list actions that are available in SharePoint Designer 2007:

  • Update List Item: update item in this list. Clicking the this list variable opens the Update List Item dialog box shown in Figure 28-12.

  • Create List Item: create item in this list. Clicking the this list variable opens the Create New List Item dialog box shown in Figure 28-13. This dialog box gives you the chance to choose which list you want to create a new item in.

  • Copy List Item: copy item in this list to this list. Clicking the first this list variable opens the Choose List Item dialog box shown in Figure 28-14; clicking the second this list variable shows a drop-down list containing all available lists.

  • Check Out Item: check out item in this list. Clicking the this list variable opens the Choose List Item dialog box (shown in Figure 28-14).

  • Check In Item: check in item in this list. Clicking the this list variable opens the Choose List Item dialog box (shown in Figure 28-14).

  • Delete Item: delete item in this list. Clicking the this list variable opens the Choose List Item dialog box (shown in Figure 28-14).

image from book
Figure 28-12: Update List Item dialog box

image from book
Figure 28-13: Create New List Item dialog box

image from book
Figure 28-14: Choose List Item dialog box

While you are designing a workflow, you can click the Check Workflow button at the bottom of the Workflow Designer page (shown in Figure 28-15) at any time to check whether your workflow is correct. If the workflow is correct, a window appears that tells you the workflow does not contain any errors. If the workflow is not correct, asterisk signs (*) appear to indicate the problem areas of your workflow.

image from book
Figure 28-15: Workflow Designer page for verifying workflow details

Adding Conditional Branches to the Workflow

For each workflow step, you can add one or more conditional branches. A conditional branch can contain one or more conditions and one or more actions. You can add a conditional branch by clicking the link called Add 'Else If' Conditional Branch in the Workflow Designer page (shown in Figure 28-15). This adds another set of conditions and actions to the workflow.

Each conditional branch, consisting of a set of conditions and actions, can be moved up and down in the tree of conditional branches. For each conditional branch, you can also move the conditions and actions up and down. You can even specify whether you want your actions to be executed parallel or sequentially. If you choose to run actions in parallel, all actions that are a part of a particular conditional branch are run at once, simultaneously. If you choose to run actions in sequence, the first action in a particular conditional branch is run, followed by the next one and so on, until the last action of that branch has finished executing.

Generating the Workflow Definition Template and Deploying the Workflow

The next step in the workflow creation process is the generation of a workflow definition template and the deployment of the workflow. This is not hard to do because the workflow definition template is generated automatically by SharePoint Designer 2007, which is also responsible for handling the deployment of the workflow to the specified list. Clicking the Finish button in the Workflow Designer Wizard displays a window that shows an overview of the status of the workflow generation and its deployment.

Because you are designing a workflow against a specific list, and the deployment of workflows created in SharePoint Designer is taken care of for you, deployment is a much simpler process than the deployment of workflows created in the Visual Studio 2005 Designer for Windows Workflow Foundation.

image from book
Deleting a Workflow and Managing Source Files

Deleting a workflow from a list or library that was designed in SharePoint Designer 2007 does not delete the actual source files that are used to compile that workflow. Instead, the workflow is no longer associated with the list or library, although the source files remain stored in the workflow document library on the site.

You might find it useful to keep the source files around if you want to reuse items within the workflow in another workflow by copying them into the other workflow folder. Other than that, you can't do much with the source files of a deleted workflow. If you are not planning to reuse workflow items, you should remove the workflow from the workflow document library.

image from book

image from book

Real World Creating a Workflow Example

You have already learned how to employ SharePoint technology to create workflows. To illustrate the concepts discussed so far, you will now learn how to create a simple real-world workflow example.

Imagine, if you will, a company that gets regular requests from potential customers that are interested in purchasing a product. The potential customers want to learn more about the price of this product and want to receive extensive product details. The way our imaginary company deals with such requests is that it assigns an account manager that handles the request by writing a customized Request For Information (RFI) document. After writing this document, it needs to be reviewed by a colleague before sending it to the customer.

In this section, you will learn how to create a workflow that facilitates this process. To keep things simple, you will create a specific document library that contains documents that are relevant to our account managers. The SharePoint workflow springs into life as soon as a document is entered into this document library that contains the word Request in its title. As soon as that happens, a new task will be created indicating that such a document needs to be reviewed.

In order to support this workflow, you first need to go to a specific SharePoint site and create a new document library called RFI Documents. This document library will contain the documents created by account managers.

Once you have created this document library, start SharePoint Designer and open the SharePoint site that contains the RFI Documents document library. In the next procedure, you will start the creation of a new workflow.

  1. Click File, select New, and choose workflow.

  2. This opens the first step of the Workflow Designer wizard. Choose the following value for the workflow name: RFIWorkflow.

  3. Select the RFI Document document library from the drop-down list.

  4. Check the "Automatically start this workflow when a new item is created" check box.

  5. Click Next.

Since you want to create a workflow that scans the title of documents and looks for the word Request, you are going to add a workflow condition. If this condition is true the workflow needs to create a new task indicating that a new RFI document is added that needs reviewing. You will add a workflow action that is responsible for this. The next procedure explains how to create a workflow condition and action to support our basic workflow process. This procedure continues where you left off, in the middle of the Workflow Designer wizard.

  1. Click the Conditions button.

  2. Select the following condition: Title field contains keywords.

  3. Click keywords.

  4. In the textbox that appears, type the following value: Request. This results in the addition of a condition to the workflow that states that some kind of action should happen if the title contains the keyword Request.

  5. Click the Actions button.

  6. Select the following action: Create List Item.

  7. Select the "This list" variable. This opens the Create New List Item dialog box.

  8. In the Create New List Item dialog box, select Tasks from the List drop-down list.

  9. Click the Add button to add a field to the item that will be created in the Tasks list. Call this field Title and assign the following value to this field: Request. Click OK.

At this point, you have created a workflow. Click the Check Workflow button in the Workflow Designer wizard to validate the workflow and make sure that it does not contain any errors. Then, click Finish. After that, the SharePoint user interface displays a dialog box that indicates the workflow is being processed. When that is done, you can start testing the workflow by adding a new document to the RFI documents document library with the word Request in its title.

image from book

Using Custom Activities in SharePoint Designer 2007

Workflow designers cannot use SharePoint Designer 2007 to create custom activities that can be used in custom workflows. Instead, SharePoint Designer 2007 limits the use of activities and conditions to the set that has been included in the safe list that is included in the Web.config file of a SharePoint virtual server. Because of this, the workflow designer can rest assured that all activities and conditions have been pre-approved by a server administrator and thus should be safe to use. Conversely, server administrators can rest assured that workflow designers will not be able to create and deploy activities and conditions to the server without their approval.

Note 

The safe list provides a safety net: workflow designers and developers cannot deploy custom activities and conditions without the explicit consent and approval of a server administrator.

A condition consists of a custom .NET assembly containing a static method that evaluates some condition and returns a Boolean value when it is called. Developers can create custom activities and conditions that can be deployed to the server after including them within the safe list. To do this, complete the following steps:

  1. Create the activity or condition in Visual Studio 2005 Designer, compile it as a strong-named assembly, and deploy it to the global assembly cache (GAC).

  2. Add the activity or condition to the action safe list in the Web.config file of a SharePoint virtual server. The Web.config file can be found at the following location: [drive letter]:\inetpub\wwwroot\wss\virtualdirectories. Locate the <SafeControls> section in the Web.config file, and add another SafeControl element, which looks like this:

     <SafeControl Assembly="[assembly name], Version=[version number], Culture=neutral, PublicKeyToken=[public key token]" Namespace="[namespace name]" TypeName="*" Safe="True" /> 

    Note 

    .NET assemblies that contain code always have their Culture attribute set to neutral.

  3. Go to the Wss.actions file that is located in the following folder: [drive letter]:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\Workflow. In this file, you have to add an Action element, rules, and parameters before the action or condition appears in the SharePoint Designer 2007 user interface. The Action element provides Visual Studio 2005 with all the information it requires to appear and function correctly in the Visual Studio 2005 user interface. The following code listing shows a sample Action element:

     <Action Name="MyTestActivity" ClassName="[class name]" Assembly="[assembly name], Version=1.0.0.0, Culture=neutral, PublicKeyToken=[public key token]" Category="Core Actions" AppliesTo="all"></Action> 

After completing all steps, the custom activity MyTestActivity is added to the Actions list of the Workflow Designer, as shown in Figure 28-16.

image from book
Figure 28-16: The custom activity MyTestActivity is added to the Actions list

Note 

For more information about configuring web.config files and signing an assembly with a strong name, see Chapter 31 of this book.

Extending Built-in Business Document Workflows

In addition to creating custom workflows by using the Workflow Designer that is included in SharePoint Designer 2007, you can also extend the built-in business document workflows that are included in SharePoint Designer 2007. Chapter 9, "Document Management," explains which document workflows are available out of the box in SharePoint Designer 2007. You can use SharePoint Designer 2007 to edit the workflow tasks that are shipped with SharePoint Designer 2007. You can find these workflow tasks in the Workflow Tasks folder located in the root of the SharePoint site. The following list provides an overview of these workflow tasks:

  • Active.aspx This file shows all active workflow items in the tasks list.

  • AllItems.aspx This file shows all workflow tasks in the tasks list.

  • Byowner.aspx This file shows all the workflow tasks that you own in the list.

  • DispForm.aspx This file shows the contents of the workflow task after you click on a workflow task.

  • Duetoday.aspx This file shows all the workflow tasks that are due today.

  • EditForm.aspx This file shows the editable contents of the workflow task.

  • myGrTsks.aspx This file shows all the workflow tasks assigned to your team in the tasks list.

  • MyItems.aspx This file show all the workflow items assigned to you in the tasks list.

  • NewForm.aspx This file shows the new item page that allows you to create a new task item.




Microsoft Office Sharepoint Server 2007 Administrator's Companion
MicrosoftВ® Office SharePointВ® Server 2007 Administrators Companion
ISBN: 0735622825
EAN: 2147483647
Year: 2004
Pages: 299

Similar book on Amazon
Microsoft Office SharePoint Server 2007 Best Practices
Microsoft Office SharePoint Server 2007 Best Practices
Microsoft SharePoint 2010 Administrator's Companion
Microsoft SharePoint 2010 Administrator's Companion
Professional SharePoint 2010 Administration
Professional SharePoint 2010 Administration
Inside Microsoft  Office SharePoint  Server 2007
Inside Microsoft Office SharePoint Server 2007

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net