InfoPath 2010 - Sharepoint 2010 Custom Workflow Part 2

Create the Visual Studio Project for the Workflow Solution

Select New Project | Visual C# | .Net Framework 3.5 | Empty Sharepoint Project

Add a new item to the project

Right click on the project name and select Add | New Item - Select C# | Sharepoint 2010 | Sequential Workflow

The Sharepoint Customization Wizard dialog will open, select a name for the new workflow InfoPath_Workflow, Select List Workflow

Note: The site you selected must have a task and workflow history list available for the new workflow or you will receive the following error message. This might occur if you used the blank site template to create the new site.

Select the Sharepoint lists to associate the workflow with

Ensure the workflow starts automatically when a new item is created checkbox is selected and click finish

The workflow designer surface will open in Visual Studio

Select View Toolbox and pin the Toolbox open. Expand the Windows Workflow V3.0 Node

Drag a While Control into the line under the onWorkflowActivated1 shape

Drag a Code Control onto the line under the whileActivity1 shape

Expand the Sharepoint Workflow Node

Drag a OnWorkflowItemChanged activity onto the text Drop and Activity Here inside the whileActivity1 shape

Note: Workflows are stored in a gallery at the Site Collection level so the scope will be Site.

Configure the Workflow Feature

When I added the Sequential Workflow to the project a Sharepoint Feature was added, I'll now configure this Feature. 

I'll start by expanding the features folder and renaming the feature to InfoPathWorkflow. Next I'll double click the Feature name to open the Feature properties. 

I'll change the Feature title in the Title textbox and ensure the Feature scope is set to Site. I'll also verify the the InfoPathWorkflow is listed in the Items in the Feature control.

Verify/Validate the Package

In the Solution Explorer I'll double click on the Package folder.

This will bring up the properties for the package, I'll rename the package and ensure the InfoPathWorkflow is in the Items in the Package control. Next I'll Validate the package and sure there are no warnings or errors with the deployment package.

Select View | Other Windows | Package Explorer

Right click on the package and select Validate

You should see a successful validation in the output window

This completes part 2, in part 3 I'll add the custom code to log any exceptions, allow the custom workflow to start and complete when specific conditions are met and create a new site collection.


InfoPath 2010 - Sharepoint 2010 Custom Workflow Part 1

Workflow is one of the core features in Sharepoint, it is very flexible and very powerful, a handful of workflows are included out of the box but the real power of workflow is in custom workflows. For this example I'm going to create a new sequential list workflow that will create a new site collection when a InfoPath 2010 Form is submitted to a list that is running my custom workflow. The workflow will be initiated upon form submit but will not create a site collection until the site name list field is populated. The custom workflow will be deployed as a site feature.

In Part 2 I'll create a new Visual Studio solution for the custom workflow project, the project will include some exception handling in case any errors occur so I can see the output from the exception(s).

Prior to creating the Visual Studio project the following items need to be in place.

1. A demo Site Collection where the solution will be deployed
2. A customized forms list where I'll attach the workflow

Create the Sharepoint Site and List

First create a new site collection where the workflow will be deployed. Once this is in place create a new list, choose Site Actions - View All Site Content | Create. Select the Issue Tracking list type from the available list templates, for this example I will name the list Issues.

Once the Issues list has been created select the list and from the list tab in the ribbon choose customize form, this will open the form in InfoPath.

All of the default fields are ok for this example but we'll need to add a SiteName field to the form. I'll replace the Issue Status default field with the Site Name that I need for the custom workflow. Select the Issue Status text from the labels in the left column and change the text to Site Name, then select the dropdown to the right and delete this dropdown control.

Next with your cursor still in the area where the Issue Status dropdown control was double click the textbox control on the Home tab of the ribbon on the top of the page. This will add a new textbox control to the form.

The new textbox should be given a value of field1 by default. From the Fields dialog on the right side right click on the field1 property and select field properties.

Enter SiteName in the Display Name and Name properties, select ok.

Next select File and choose Quick Publish to save the changes to the form in Sharepoint.

This completes part 1, in part 2 I'll create the Visual Studio Solution with the custom workflow


Windows Server 2008 R2 - Disable Firewall

I always disable the Windows firewall on all of my development virtual machines, this is a quick and easy way to avoid frustration with connectivity issues.

Here is the command I use to disable the firewall. Open an elevated command prompt ( right click cmd.exe icon and select run as administrator)

netsh advfirewall set allprofiles state off

This will immediately disable all firewall profiles.