Step 1: Create the Workflow Initiation Form

By using Microsoft Office InfoPath 2007, you can create workflow forms that run in 2007 Microsoft Office system client applications—such as Microsoft Office Excel 2007, Microsoft Office Word 2007, Microsoft Office PowerPoint XML Format, and InfoPath Forms Services itself—as well as in a Web browser.

The steps in this procedure follow procedures described in How to: Design an InfoPath Form for a Workflow in Office SharePoint Server 2007.

Note

This procedure assumes you are familiar with adding controls to a Microsoft Office InfoPath 2007 form and configuring those controls.

To create the workflow initiation form

  1. Open Microsoft Office InfoPath 2007. In the Fill Out a Form dialog box, click Design a Form.

  2. In the Design a Form dialog box, select Blank, select Enable browser-compatible features only, and then click OK.

  3. In the Design Tasks pane, click Controls.

  4. On the form, add the following controls to capture the information the workflow requires:

    1. On the form surface, type Assign Task To:, press Enter and then drag a text box control onto the form below the label. Right-click the text box control, and then select Text Box Properties. For Field Name, type assignee, and then click OK.

    2. Type Instructions:, press Enter, and then drag another text box control onto the form. Right-click the text box control, and select Text Box Properties. For Field Name, type instructions, and then click OK.

    3. Type Comments:, press Enter, and then drag another text box control onto the form. Right-click the text box control, and then select Text Box Properties. For Field Name, type comments, and then click OK.

    4. Drag a button control onto the form. Right-click the button control and then select Button Properties. On the General tab, for Label, type submit, and then click OK.

    When finished, your form should resemble the following figure.

    Workflow initialization form

    Notice that we have named the text fields assignee, instructions, and comments. These text field names will be used later to populate the SPWorkflowActivationProperties that are called from the onWorkflowActivated activity in the workflow code. When the form submits its data to Microsoft Office SharePoint Server 2007, Office SharePoint Server 2007 starts a new workflow instance and adds these custom properties to the SPWorkflowActivationProperties object as name and value pairs. Your workflow code can then retrieve the data by accessing those name and value pairs.

    For more information, see How to: Design a Workflow Form to Use Association and Initiation Data.

  5. Give the form fields collection a unique name. From the Design Tasks pane, click Data Source. You will see the field names you entered for the controls on the form designer. Right-click myFields and select Properties. In the Field or Group Properties dialog, type InitForm for the Name property.

    Later in this procedure, you will extract the schema from this form to create a schema (.xsd) file. This schema then becomes the basis for the class you will create and reference in the onWorkflowActivation activity. The form fields collection name will become the name of the root element of the schema file. The class that is generated from the schema file, in turn, will have the same name as the schema file root element.

    Specifying a unique name for the fields collection as we did previously, rather than using the default name of myfields, will help ensure that the class generated from the form schema file will also have a unique name. This is especially important when you are programming a workflow that deserializes multiple forms.

  6. Add rules to the Submit button: One rule submits the form information to the hosting environment (in this case, Office SharePoint Server 2007); the other closes the form when the user clicks Submit.

    1. Right-click the button, and then select Button Properties.

    2. In the Button Properties dialog box, on the General tab, click Rules, then click Add.

    3. Click Add Action, and then click Submit using a data connection. Click Add.

    4. In the Data Connection Wizard, select Create a new connection to and submit data, and then click Next.

    5. Under How do you want to submit your data, select To the hosting environment, and then click Next. Click Finish, and then click OK.

    6. Add another rule: On the Rules dialog box, click Add and then click Add Action.

    7. Select Close the Form from the list of predefined actions. Make sure If changes have not been saved, prompt user to save is not selected.

    8. Click OK to exit from the various dialog boxes.

  7. Set the security level of the form to Domain.

    1. On the Tools menu, select Forms Options, and then select Security and Trust.

    2. Clear Automatically determine security level, and then select Domain.

  8. Publish the form.

    1. Save the form.

    2. On the File menu, click Publish.

    3. In the Publishing Wizard, select To anetwork location, and then click Next.

    4. Browse to the network location where you want to publish the form, and then click OK.

    5. For Form Name, type InitiationForm, and then click Next.

    6. Click Next.

      Note

      Do not specify an alternate path to the form. Doing this will cause an error that prevents you from publishing the form to the server.

    7. Click Publish, and then click Close.

  9. Generate a new class file, based on the form schema (.xsd) file.

    1. On the File menu, click Save as Source Files. Browse to the location where you want to save the form source files, and then click OK.

      InfoPath saves a collection of form source files, including the schema file, to the specified location. The form schema file is always named myschema.xsd.

    2. Use the Microsoft .NET Framework 2.0 command-line tool--xsd.exe--to generate a new class file from the form schema.

      By default, Visual Studio 2005 installs the xsd.exe command-line tool to the following location, where C: represents your hard disk:

      C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin

    3. Open a Visual Studio Command Prompt window. Click the Start button, select All Programs, select Microsoft Visual Studio 2005, select Visual Studio Tools, and then click Visual Studio 2005 Command Prompt.

    4. Navigate to the location of the form schema (.xsd) file, and then run the following command:

      xsd myschema.xsd /c /l:CS
      

      or

      xsd myschema.xsd /c /l:VB
      

      depending on the language you are using to develop your workflow.

      This command generates a new class file based on the form schema. The file will be created with the same name as the schema file. In this case it would be myschema.cs. The base class created in the file will have the same name as the root element of the schema, which was given the same name as the form fields collection. In this walkthrough the name is InitForm.

    5. In Visual Studio, add the new class file to your workflow project.

Next Steps

Step 2: Creating the Workflow Task Edit Form

See Also

Concepts

Workflows in Office SharePoint Server 2007
InfoPath Forms for Workflows