You are on page 1of 26

To demonstrate how to design Office InfoPath forms for workflows in SharePoint Server 2007, this section

walks through eight important steps:

1. Creating the workflow initiation form.

2. Creating the workflow task edit form.

3. Creating a SharePoint Sequential Workflow Library project in Visual Studio.

4. Adding code to respond to workflow activation.

5. Designing the workflow by using Microsoft Visual Studio 2005 Designer for Windows Workflow
Foundation.

6. Setting the properties of the workflow activities.

7. Signing the workflow library assembly with a strong name.

8. Deploying the workflow.

Creating the Workflow Initiation Form

The workflow initiation form is displayed to the user when the workflow is first activated. To create the
workflow initiation InfoPath form, do the following:

1. Open Office InfoPath 2007. In the Getting Started dialog box, click Design a Form Template.

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

3. In the Design Tasks pane, click Controls.

4. On the form, add the following controls:

a. Type Assign Task To:, press Enter, and then drag a text box control onto the form from the
Controls pane. Right-click the text box control, and then click Text Box Properties. For
Field name, type assignee. Click Apply. On the Size tab, set the width to 300 px, and then
click OK.

b. On the form, press the right-arrow key once, and then press Enter twice. Type Instructions:,
press Enter, and then drag another text box control onto the form. Right-click the text box
control, and then click Text Box Properties. For Field name, type instructions. Click
Apply. On the Size tab, set the width to 300 px, and then click OK.

c. On the form, press the right-arrow key once, and then press Enter twice. Type Comments:,
press Enter, and then drag another text box control onto the form. Right-click the text box
control, and then click Text Box Properties. For Field name, type comments. Click Apply.
On the Size tab, set the width to 300 px, and then click OK.
d. On the form, press the right-arrow key once, and then press Enter twice. Drag a button
control onto the form from the Controls pane. Right-click the button control, and then click
Button Properties. On the General tab, for Label, type Submit, and then click OK.

The form should look like Figure 1.

Figure 1. Workflow initiation form

Note:

The text fields are named assignee, instructions, and comments. You reference these fields by these
names in the section of this article titled "Adding Code to Respond to Workflow Activation," when you
add code to the workflow to work with the initiation form data.

5. Give the form fields collection a unique name:

a. In the Design Tasks pane, click Data Source.

b. In the Data Source pane, right-click MyFields, and then click Properties.

c. In the Field or Group Properties dialog box, for Name, type InitForm.
d. Click OK to save the change.

Later in this article, you extract the schema (.xsd) file for this form and use it as the basis for the
class referenced in the workflow code that processes the initiation form data. The root element of
the schema file is named the same as the form fields collection. The class generated from the
schema file has the same name as the schema file root element.

Specifying a unique name for the fields collection, rather than using the default name of myFields,
helps ensure that the class that is generated from the form schema file also has a unique name.
This is especially important when programming a workflow that deserializes multiple forms.

6. Add rules to the Submit button:

Note:

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

a. Right-click the Submit button control on the form, and then click Button Properties.

b. In the Button Properties dialog box, on the General tab, click Rules.

c. In the Rules dialog box, click Add.

d. In the Rule dialog box, click Add Action. In the Action drop-down list, select Submit using
a data connection, and then click Add.

e. In the Data Connection Wizard, click Create a new connection to and Submit data, and
then click Next.

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

g. Click OK to close the Action dialog box.

h. Click OK to close the Rule dialog box.

i. In the Rules dialog box, click Add.

j. In the Rule dialog box, click Add Action.

k. In the Action drop-down list, select Close the form, and then click OK.

l. Click OK to close the Rule dialog box.

m. Click OK to close the Rules dialog box.

n. Click OK to close the Button Properties dialog box.


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

a. On the Tools menu, click Form Options.

b. In the Form Options dialog box, in the Category list, click Security and Trust.

c. Under Security Level, clear the Automatically determine security level check box, and
then click Domain.

d. Click OK to save the changes and close the Form Options dialog box.

8. Publish the form:

a. On the File menu, click Save As. In the Save As dialog box, for File name, type
InitForm.xsn. Save the form to any location.

b. On the File menu, click Publish.

c. In the Publishing Wizard, select To a network location, and then click Next.

d. Click Browse. In the Browse dialog box, navigate to the folder where you want to publish the
form. For File name, type InitForm, and then click OK.

e. In the Publishing Wizard, for Form template name type InitForm, and then click Next.

f. Clear the alternate path to the form from the text box, and then click Next.

Note:

Do not specify an alternate path to the form. If you specify an alternate path, it causes an error that
prevents publishing the form to the server.

g. Click Publish, and then click Close.

9. Determine the ID of the InitForm form:

a. On the File menu, click Properties.

Figure 2. Form Template Properties dialog box


b. In the Form Template Properties dialog box, note the ID. You will use the form ID when
you deploy the workflow.

c. Click Cancel to close the Form Template Properties dialog box.

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

a. 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.

b. On the File menu, click Close to close the form in InfoPath.

Next, you use the Microsoft .NET Framework 2.0 command-line tool, xsd.exe, to generate a
new class file from the form schema.

c. In Visual Studio 2005, open a Visual Studio Command window, navigate to the location of the
myschema.xsd file, and then run the following command:
Copy Code

xsd myschema.xsd /c /l:language

d. Replace language with either VB or CS, depending which language you will write the workflow
in. This command generates a new class file based on the form schema. The file is named the
same as the schema file, that is, myschema.cs or myschema.vb, and is located in the current
directory. The class in the file is named the same as the root element of the schema, which
was named the same as the form fields collection.

Note:

If the form is still open in InfoPath, xsd returns an error stating that it cannot access the file because it is
being used by another process.

11. Rename the myschema.cs or myschema.vb file to InitForm.cs or InitForm.vb.

Creating the Workflow Task Edit Form

1. Open Office InfoPath 2007. In the Getting Started dialog box, click Design a Form Template.

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

3. In the Design Tasks pane, click Controls.

4. Add controls:

a. On the form, type Comments:, press Enter, and then drag a text box control onto the form
from the Controls pane. Right-click the text box control, and then click Text Box Properties.
For Field name, type comments. Click Apply. On the Size tab, set the width to 300 px, and
then click OK.

b. On the form, press the right-arrow key once, and then press Enter twice. Drag a check box
control onto the form. Right-click the check box control, and then click Check Box
Properties. For Field name, type isFinished, and then click OK.

c. Next to the check box, select the text Field 2. Type Complete Task, to replace the text Field
2. Press Enter twice.

d. Drag a button control onto the form. Right-click the button control, and then click Button
Properties. On the General tab, for Label, type OK. Click Apply. On the Size tab, set the
width to 80 px, and then click OK.

The form should look like Figure 3.

Figure 3. Workflow task edit form


5. Add the same rules to the OK button as you previously added to the Submit button of the initiation
form. (See Step 6 of the section Creating the Workflow Initiation Form.)

6. Create a schema file for the workflow task schema:

a. In a text editor, such as Notepad, create a file named ItemMetadata.xml.

Note:

The file name is case-sensitive.

b. Add the following markup to the ItemMetadata.xml file.

Xml
Copy Code
<z:row xmlns:z="#RowsetSchema"
ows_comments=""
/>

c. Save the ItemMetadata.xml file.

7. Add the workflow task schema to the task edit form as a secondary data source:
a. In Office InfoPath 2007, on the Design Tasks pane, select Data Source, and then click
Manage Data Connections.

b. In the Data Connections dialog box, click Add.

c. In the Data Connection Wizard, click Create a new connection to and Receive data, and
then click Next.

d. Click XML document, and then click Next.

e. Click Browse, navigate to the folder where you saved ItemMetadata.xml, select it, and then
click Open. Click Next.

f. Click Include the data as a resource file in the form template or template part, and
then click Next.

g. Type ItemMetadata as the data connection name, and ensure that the Automatically
retrieve data when form is opened check box is selected. Click Finish. Click Close.

After you include the ItemMetadata.xml file as a resource file in the form template, the file is
no longer needed in the workflow solution.

Note:

ItemMetadata.xml is required as a secondary data source for task forms. If you do not add
ItemMetadata.xml as a secondary data source, the form generates an error upon opening.

8. Data-bind the Comments text box control to the comments elements in the workflow task schema:

a. On the form, right-click the text box control, and then click Text Box Properties.

b. In the Text Box Properties dialog box, on the Data tab, in the Default Value section, click
the formula button.

c. In the Insert Formula dialog box, click Insert Field or Group.

d. In the Select a Field or Group dialog box, in the Data source list, select ItemMetadata.

e. Click the ows_comments element, and then click OK.

f. In the Insert Formula dialog box, click OK.

g. In the Text Box Properties dialog box, click OK.

The Comments text box control is now bound to the comments workflow task property. When
Office SharePoint Server 2007 loads the task form, the form displays the task comments in the
text box.

9. Set the security level of the form to Domain:


a. On the Tools menu, click Form Options.

b. In the Form Options dialog box, in the Category list, click Security and Trust.

c. Under Security Level, clear the Automatically determine security level check box, and
then click Domain.

d. Click OK to save the changes and close the Form Options dialog box.

10. Publish the form:

a. On the File menu, click Save As. In the Save As dialog box, for File name, type
TaskForm.xsn. Save the form to any location.

b. On the File menu, click Publish.

c. In the Publishing Wizard, select To a network location, and then click Next.

d. Click Browse. In the Browse dialog box, navigate to the folder where you want to publish the
form. For File name, type TaskForm, and then click OK.

e. In the Publishing Wizard, for Form template name type TaskForm, and then click Next.

f. Clear the alternate path to the form from the text box, and then click Next.

Note:

Do not specify an alternate path to the form. If you specify an alternate path, it causes an error that
prevents publishing the form to the server.

g. Click Publish, and then click Close.

11. Determine the ID of the TaskForm form:

a. On the File menu, click Properties.

Figure 4. TaskForm form template properties


b. In the Form Template Properties dialog box, note the ID. You will use the form ID when
you deploy the workflow.

c. Click Cancel to close the Form Template Properties dialog box.

Creating a SharePoint Sequential Workflow Library Project in Visual Studio 2005

To create a SharePoint Sequential Workflow Library project in Visual Studio 2005:

1. Start Visual Studio.

2. On the File menu, click New, and then click Project.

3. In the New Project dialog box, in the Project types pane, select Visual C# or Visual Basic for the
project type, and then click SharePoint.

4. In the Templates pane, click Sequential Workflow Library. Type InfoPathFormWorkflowLibrary


as the project Name, specify a Location for the project, and then click OK.

Visual Studio creates a new solution containing the workflow library project.

Figure 5. Creating a SharePoint Sequential Workflow Library Project


5. Add the InitForm.cs or InitForm.vb class file that you created previously for the initiation form
schema to the InfoPathFormWorkflowLibrary project:

a. In Solution Explorer, right-click the InfoPathFormWorkflowLibrary project, click Add, and then
click Existing Item.

b. In the Add Existing Item dialog box, navigate to the folder that contains the InitForm.cs or
InitForm.vb file that you created previously, select the file, and then click Add.

The class file is added to the project.

6. Add the InitForm.xsn and TaskForm.xsn files that you created previously (when you published the
initiation and task edit forms) to the InfoPathFormWorkflowLibrary project:

a. In Solution Explorer, right-click the InfoPathFormWorkflowLibrary project, click Add, and then
click Existing Item.

b. In the Add Existing Item dialog box, navigate to the folder that contains the InitForm.xsn
and TaskForm.xsn files that you created previously, select the files, and then click Add.
The form template files are added to the project.

Adding Code to Respond to Workflow Activation

To display the workflow outline:

In Solution Explorer, expand the InfoPathFormWorkflowLibrary project node, and then double-click
the Workflow1.cs file.

The initial workflow outline is displayed in the Workflow Designer, showing the OnWorkflowActivated activity
added by Visual Studio.

Figure 6. Initial workflow outline

The OnWorkflowActivated activity runs when the workflow is first activated. It is a good place to process the
information specified by the user via the workflow initiation form.

To add a method that is called when the OnWorkflowActivated activity is run, set the Invoked property of
the onWorkflowActivated1 activity:

1. Right-click the onWorkflowActivated1 activity, and then click Properties.


2. In the Properties pane, type onWorkflowActivated as the value of the Invoked property, and
then press Enter.

Visual Studio opens the Workflow1.cs or Workflow1.vb file in the code editor with the generated
onWorkflowActivated method visible.

3. In the Workflow1.cs or Workflow1.vb file, add the following Imports or using statements below the
Imports or using statements generated by Visual Studio.

Visual Basic
Copy Code
Imports System.Xml
Imports Microsoft.SharePoint.Workflow
C#
Copy Code
using Microsoft.SharePoint.Workflow;

4. Add the following string variable declarations to the Workflow1 class.

Visual Basic
Copy Code
Private assignee As String = String.Empty
Private instructions As String = String.Empty
Private comments As String = String.Empty
Private isFinished As Boolean = False
Public workflowId As Guid
C#
Copy Code
private String assignee = default(String);
private String instructions = default(String);
private String comments = default(String);
private bool isFinished = false;

5. Add the following code to the onWorkflowActivated method to parse the incoming workflow
initiation data.

Visual Basic
Copy Code
workflowId = workflowProperties.WorkflowId

Dim serializer As XmlSerializer = New XmlSerializer(GetType(InitForm))


Dim reader As XmlTextReader = New XmlTextReader( _
New System.IO.StringReader(workflowProperties.InitiationData))
Dim initform As InitForm = _
CType(serializer.Deserialize(reader), InitForm)

assignee = InitForm.assignee
instructions = InitForm.instructions
comments = InitForm.comments
C#
Copy Code
workflowId = workflowProperties.WorkflowId;

XmlSerializer serializer = new XmlSerializer(typeof(InitForm));


XmlTextReader reader = new XmlTextReader(
new System.IO.StringReader(workflowProperties.InitiationData));
InitForm initform = (InitForm)serializer.Deserialize(reader);

assignee = initform.assignee;
instructions = initform.instructions;
comments = initform.comments;
Designing the Workflow

To design the outline of the workflow:

1. Switch to the workflow designer window.

2. Open the Visual Studio toolbox.

3. Drag a CreateTask activity, a WhileActivity activity, and a CompleteTask activity, in that order,
to the workflow outline.

4. Drag an OnTaskChanged activity inside the whileActivity1 activity.

Figure 7. Final workflow outline


Note:

If the SharePoint workflow activities are not visible in the Visual Studio toolbox, you can load them:
In workflow design mode, right-click the Toolbox, and then click Choose Items.
On the Activities tab, browse to the %programfiles%/Common Files/Microsoft Shared/web
server extensions/12/ISAPI folder, and select the Microsoft.SharePoint.WorkflowActions.dll file, and
then click OK.
Setting Workflow Activity Properties

The Workflow Designer displays red exclamation marks next to each of the workflow activities that you
added in the previous step. For the task-related activities, this is because you have not set their correlation
token property yet. A correlation token is a unique identifier that enables mapping between the objects in a
workflow and the environment hosting the Windows Workflow Foundation (WF) workflow runtime.

To set the properties for the task-related activities:


1. Right-click the Workflow Designer surface, and then click View Code to open the workflow code file
.

The Workflow1.cs or Workflow1.vb file is displayed in the code editor.

2. In the Workflow1.cs or Workflow1.vb file, add the following lines of code to the body of the
Workflow1 class, just below the line that Visual Studio generated that defines the
workflowProperties variable.

Visual Basic
Copy Code
Public taskId As Guid = Guid.Empty
Public taskProperties As SPWorkflowTaskProperties = _
New SPWorkflowTaskProperties()
C#
Copy Code
public Guid taskId = default(System.Guid);
public SPWorkflowTaskProperties taskProperties =
new SPWorkflowTaskProperties();

3. Switch to the workflow design view, right-click the createTask1 activity, and then click
Properties.

4. In the Properties pane, type taskToken as the value of the CorrelationToken property, and then
press Enter.

A plus sign is displayed to the left of the CorrelationToken property.

5. Click the plus sign to display the OwnerActivityName property. Set its value by expanding the
property value dropdown list and clicking Workflow1.

6. Click the TaskId property, and then click the ellipses (…) button.

7. In the Property Bind dialog box, click the taskId property that you created in Step 2, and then
click OK.

Figure 8. Binding the TaskId property


8. Click the TaskProperties property, and then click the ellipses (….) button.

9. In the Property Bind dialog box, click the taskProperties property that you created in Step 2,
and then click OK.

Figure 9. Binding the TaskProperties property


10. Right-click the onTaskChanged1 activity, and then click Properties.

11. In the Properties pane, click the CorrelationToken property. Set its value by expanding the
property value dropdown list and clicking taskToken.

12. Click the TaskId property, and then click the ellipses (….) button.

13. In the Bind dialog box, click the taskId property that you created in Step 2, and then click OK.

14. Click the AfterProperties property, and then click the ellipses (….) button.

15. In the Property Bind dialog box, click the taskProperties property that you created in Step 2,
and then click OK.

16. Right-click the completeTask1 activity, and then click Properties.

17. In the Properties pane, click the CorrelationToken property. Set its value by expanding the
property value dropdown list and clicking taskToken.

18. Click the TaskId property, and then click the ellipses (….) button.

19. In the Property Bind dialog box, click the taskId property that you created in Step 2, and then
click OK.
At this point, the taskId variable used for the TaskId property of the task-related activities has a default
GUID value of all zeros. The title property of the taskProperties variable is not set. To initialize these
variables, do the following:

1. In the workflow designer, double-click the createTask1 activity.

Visual Studio switches to the Workflow1.cs or Workflow1.vb file and displays the body of the
createTask1_MethodInvoking method. This method is called prior to the createTask1 activity
being started.

2. Add the following code to the body of the createTask1_MethodInvoking method.

Visual Basic
Copy Code
taskId = Guid.NewGuid()
taskProperties.Title = "Task for " + workflowProperties.Item.Name
taskProperties.Description =
"A task from the InfoPath forms workflow."
taskProperties.ExtendedProperties("Assignee") = assignee
taskProperties.ExtendedProperties("Comments") = comments
taskProperties.ExtendedProperties("Instructions") = instructions
C#
Copy Code
taskId = Guid.NewGuid();
taskProperties.Title = "Task for " + workflowProperties.Item.Name;
taskProperties.Description =
"A task from the InfoPath forms workflow.";
taskProperties.ExtendedProperties["Assignee"] = assignee;
taskProperties.ExtendedProperties["Comments"] = comments;
taskProperties.ExtendedProperties["Instructions"] = instructions;

3. The next step is to set the properties of the While activity. The While activity causes the activities
inside it to loop as long as the condition it evaluates resolves to true. In this example, it is used to
loop around the TaskChanged activity until the user explicitly completes the task.

4. To set the properties of the While activity:

a. Switch to the workflow design view, right-click the whileActivity1 activity, and then click
Properties.

b. In the Properties pane, type Code Condition as the value of the Condition property.

This tells the While activity that it is calling a method to determine to end the loop. A plus
sign is displayed to the left of the Condition property.
c. Click the plus sign, type notFinished as the value of the Condition subproperty, and then
press Enter.

Visual Studio switches back to code view and displays the code for the generated notFinished
method.

5. Add the following code to the notFinished method:

Visual Basic
Copy Code
e.Result = Not isFinished
C#
Copy Code
e.Result = !isFinished;

6. This code checks the value of the isFinished variable. The value of the isFinished variable is set
depending on whether the user checked the Complete Task check box on the workflow task edit
form. To set the value of the isFinished variable, add a method that is called when the
TaskChanged activity is run:

7. Switch to the workflow design view, right-click the onTaskChanged1 activity, and then click
Properties.

8. In the Properties pane, type onTaskChanged as the value of the Invoked property, and then
press Enter.

Visual Studio switches to code view and displays the code for the generated onTaskChanged
method.

9. Add the following code to the onTaskChanged method:

Visual Basic
Copy Code
isFinished = Boolean.Parse( _
taskProperties.ExtendedProperties("isFinished").ToString())
C#
Copy Code
isFinished = bool.Parse(
taskProperties.ExtendedProperties["isFinished"].ToString());

Each time the user edits the task, the onTaskChanged1 activity handles the task changed event. It
invokes the onTaskChanged method, which examines the task properties and sets the isFinished variable
to represent whether the user marked the task as complete. The while1 activity then invokes the
notFinished method, which sets the result of the event to the opposite of the isFinished variable. If
isFinished is equal to false, the event result is set to true, and the while1 activity waits for task changes.
If isFinished is equal to true, the event result is set to false, the while1 activity completes, and the
workflow continues to the next activity. The next activity is the CompleteTask activity, which sets the task
as complete.
Signing the Workflow Library Assembly with a Strong Name

For the workflow library assembly to be installed in the Global Assembly Cache, it must be signed with a
strong name. A strong name consists of the assembly's identity—its simple text name, version number, and
culture information (if provided)—plus a public key and a digital signature. To assign a strong name to the
assembly in Visual Studio:

1. On the Project menu, click Properties, and then click ProjectName.

2. On the Project Properties page, on the Signing tab, select the Sign the assembly check box.

3. In the Choose a strong name key file list, click New.

4. In the Create Strong Name Key dialog box, type Keyfile as the key file name, and then clear the
Protect my key file with a password check box.

5. Close the Project Properties page.

6. Build the workflow library.

Deploying the Workflow

When Visual Studio created the InfoPathFormWorkflowLibrary project, it created two deployment-related
files: Feature.xml and Workflow.xml. Feature.xml defines the workflow as an installable SharePoint feature.
Workflow.xml defines the actual workflow. Initially, these files contain only instructions for how to insert the
necessary code to define the workflow feature and the workflow. To modify the Feature.xml and
Workflow.xml files to work with the InfoPathFormWorkflowLibrary workflow:

1. Open the Feature.xml file and replace its contents with the following markup.

Xml
Copy Code
<?xml version="1.0" encoding="utf-8"?>
<!-- _lcid="1033" _version="12.0.3111" _dal="1" -->
<!-- _LocalBinding -->

<Feature Id="GUID"
Title="InfoPath Form Workflow"
Description="This feature is a workflow that demonstrates using
InfoPath forms."
Version="12.0.0.0"
Scope="Site"
ReceiverAssembly="Microsoft.Office.Workflow.Feature,
Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"

ReceiverClass="Microsoft.Office.Workflow.Feature.WorkflowFeatureReceiver"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="workflow.xml" />
</ElementManifests>

<Properties>
<Property Key="GloballyAvailable" Value="true" />
<!-- Value for RegisterForms key indicates the path to the
forms relative to the feature file location -->
<Property Key="RegisterForms" Value="Forms\*.xsn" />
</Properties>
</Feature>

2. Replace the GUID placeholder text in the <Feature Id> attribute with a unique GUID. You can
generate a unique GUID from within Visual Studio:

a. On the Tools menu, click Create GUID to launch the Create GUID tool.

b. In the Create GUID tool, click Registry Format, and then click Copy to copy the GUID to the
Clipboard.

c. Paste the GUID into the markup, replacing the GUID placeholder text. Do not include the
opening and closing curly braces.

Figure 10. Creating a GUID


3. Open the Workflow.xml file and replace its contents with the following markup.

Xml
Copy Code
<?xml version="1.0" encoding="utf-8" ?>
<!-- _lcid="1033" _version="12.0.3015" _dal="1" -->
<!-- _LocalBinding -->

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Workflow
Name="InfoPath Form Workflow"
Description="This workflow demonstrates using InfoPath forms."
Id="GUID"
CodeBesideClass="InfoPathFormWorkflowLibrary.Workflow1"
CodeBesideAssembly="InfoPathFormWorkflowLibrary,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=publicKeyToken"
InstantiationUrl="_layouts/IniWrkflIP.aspx"
ModificationUrl="_layouts/ModWrkflIP.aspx"
StatusUrl="_layouts/WrkStat.aspx"
TaskListContentTypeId="0x01080100C9C9515DE4E24001905074F980F93160" >

<Categories/>
<MetaData>
<Instantiation_FormURN>
InitFormID
</Instantiation_FormURN>
<Task0_FormURN>
TaskFormID
</Task0_FormURN>
</MetaData>
</Workflow>
</Elements>

a. Use the process described in Step 2 of the section "Deploying the Workflow" to replace the
GUID placeholder text in the <Workflow Id> attribute with a unique GUID.

b. Use the Strong Name (sn.exe) tool that is included with Visual Studio to determine the public
key token of the InfoPathFormWorkflowLibrary assembly. Open a Visual Studio Command
Window and navigate to the folder that contains the assembly. Run sn.exe with the -T option
against the assembly, like this:

Copy Code

sn.exe -T InfoPathFormWorkflowLibrary.dll

c. Notice the returned public key token and then replace the publicKeyToken placeholder text
used with the CodeBesideAssembly attribute with the token returned by sn.exe.

d. Replace the InitFormID and TaskFormID placeholders used with the Instantiation_FormURN
and Task0_FormURN MetaData nodes with the InitForm and TaskForm form IDs determined
previously from within InfoPath.

e. Save the changes to the Feature.xml and Workflow.xml files.

4. Edit the contents of the Install.bat file, replacing the text generated by Visual Studio with the
following:

Copy Code
echo Copying the feature...

rd /s /q "%CommonProgramFiles%\Microsoft Shared\web server


extensions\12\TEMPLATE\FEATURES\InfoPathFormWorkflowLibrary"
mkdir "%CommonProgramFiles%\Microsoft Shared\web server
extensions\12\TEMPLATE\FEATURES\InfoPathFormWorkflowLibrary"
mkdir "%CommonProgramFiles%\Microsoft Shared\web server
extensions\12\TEMPLATE\FEATURES\InfoPathFormWorkflowLibrary\Forms"
copy /Y feature.xml "%CommonProgramFiles%\Microsoft Shared\web server
extensions\12\TEMPLATE\FEATURES\InfoPathFormWorkflowLibrary\"
copy /Y workflow.xml "%CommonProgramFiles%\Microsoft Shared\web server
extensions\12\TEMPLATE\FEATURES\InfoPathFormWorkflowLibrary\"
xcopy /s /Y *.xsn "%CommonProgramFiles%\Microsoft Shared\web server
extensions\12\TEMPLATE\FEATURES\InfoPathFormWorkflowLibrary\Forms"

echo Adding assemblies to the GAC...

"%programfiles%\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" -uf


InfoPathFormWorkflowLibrary
"%programfiles%\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" -if
bin\Debug\InfoPathFormWorkflowLibrary.dll

:: Note: 64-bit alternative to lines above; uncomment these to install on a


64-bit computer
::"%programfiles% (x86)\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe"
-uf InfoPathFormWorkflowLibrary
::"%programfiles% (x86)\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe"
-if bin\Debug\InfoPathFormWorkflowLibrary.dll

echo Activating the feature...

pushd %programfiles%\common files\microsoft shared\web server


extensions\12\bin

::Note: Uncomment these lines if you've modified your deployment xml files
or IP forms
stsadm -o deactivatefeature -filename InfoPathFormWorkflowLibrary
\feature.xml -url http://localhost
stsadm -o uninstallfeature -filename InfoPathFormWorkflowLibrary
\feature.xml

stsadm -o installfeature -filename InfoPathFormWorkflowLibrary \feature.xml


-force
stsadm -o activatefeature -filename InfoPathFormWorkflowLibrary
\feature.xml -url http://localhost

echo Doing an iisreset...


popd
iisreset
a. Replace the localhost URL used with the stsadm command with the URL of the SharePoint site
collection being deployed to.

b. When deploying a release mode build of the workflow, change the build folder in the path used
with the gacutil.exe -if command from Debug to Release.

5. Build the InfoPathFormWorkflowLibrary project and then run the Install.bat file to deploy the
workflow. After the deployment succeeds, you can associate the workflow with a SharePoint list,
library, or content type and then test it. For more information about how to associate a workflow
with a list, library, or content type, refer to the Add or Change a Workflow for a List, Library, or
Content type [ http://office.microsoft.com/en-us/sharepointserver/HA101720071033.aspx ] on
Microsoft Office Online.

You might also like