Paul Schaeflein

All MindsharpBlogs

My Links

Post Categories


Blog Stats


Porting a SharePoint Designer (SPD) Workflow to Visual Studio.Net – Part 1

I am working on getting a community site up to host these articles as well as the code. My hope is that all interested developers will contribute their solution to the various Actions that can be selected in SharePoint designer.

This post is the first in a series. The series will discuss the porting steps as we presented in Seattle, but with the details filled in. (We had only 75 minutes to present, which is way too little.) Part 1 will discuss the virtual machine setup and the creation of the SharePoint Designer workflow that will be ported.

Virtual Machine Setup

When a workflow is created in SharePoint Designer, the site is updated with a few pieces that enable it to work. We want to ensure that we port all of these pieces, so we will be using two different web applications. The first at http://spdflow will be used for the SharePoint Designer workflow. The second at http://vsflow will host the Visual Studio workflow. Rather than use different port numbers for the web application, the hosts file (C:\WINDOWS\system32\drivers\etc\hosts) is updated with each of these host names.

The virtual machine will also have the necessary applications installed: SharePoint Designer 2007 and Visual Studio 2005 with the Office SharePoint Server 2007 SDK.

SharePoint Designer

We will use SharePoint Designer to create a workflow. The workflow will perform the most popular actions -- collecting data, creating a task and writing to the history list. This is accomplished via the following steps:

  • In SharePoint Designer, open the site http://spdflow.
  • Click File | New | Workflow. The Workflow Designer wizard is displayed.
  • Name the workflow SPDFlow and attach it to the Announcements list. Leave the start options at the default, which is manually. (We'll be starting it often.)

  • Click on the Initiation button on the bottom
  • Add a Workflow Initiation Parameter named InitiationField with a default value of Barracuda. Then click OK

  • Back in the Workflow Designer wizard, Click Next.
  • In Step 1, click on the Conditions button and choose Compare Announcements field.

  • Choose the Modified By field and the account name of the current user.

  • Click on the Actions button and choose Collect Data from User.

  • Click on the "data" link to invoke the Custom Task Wizard.

  • Enter "Collect Data Task" for the task name and click Next

  • Click Add to create a field.

  • Name the field "TaskField" and enter a default value of "DeliverPoint"

  • Click Finish on the Custom Task Wizard. You will receive a warning about running instances, which can be ignored.
  • Click on the "this user" link in Step 1 Actions. Select the account name for the current user.

  • Click on the "Variable: collect" link in Step 1 Actions. Rather than put the data in a generically named variable called "collect," choose "Create a new variable" and name it "ListItemID"

  • Click on the Variables button at the bottom of the Workflow Designer form. Even though we did not choose the variable named "collect," it was created for us. Remove it, and any other unused variables, from the list.
  • Click Finish.

SharePoint Designer will save the workflow and associate it with the Announcements list. Test the workflow by returning to the browser and navigating to the Announcements list.

  • On the context menu of a list item, select Workflows

  • On the Workflows page in the Start a New Workflow section, click on the name of the workflow (SPDFlow)

  • The initiation form is displayed. Click Start

  • The Announcements list is displayed, with a new column on the far right. The column name matches the name of the workflow and the value is "In Progress"

  • Click on "In Progress" to display the Workflow Status page

  • In the middle of the page is the name of the task: CollectDataTask. Click on this link to display the task.

  • Click on Edit Item in the tool bar. This will display the custom task edit form for this workflow

  • Click on Complete Task

    At this point we have a workflow that was created in SharePoint Designer. The next post is this series will move us further along our path. Stay tuned!

posted on Wednesday, March 12, 2008 4:33 AM


# re: Porting a SharePoint Designer (SPD) Workflow to Visual Studio.Net – Part 1 3/12/2008 6:17 PM Randy Williams

I really enjoyed Todd's presentation, but sure wish he had more time. Great job guys compiling this. Very much look forward to the continuing posts.

# re: Porting a SharePoint Designer (SPD) Workflow to Visual Studio.Net – Part 1 3/13/2008 4:52 PM Jerry


Great Post. Looking forward to the next one. I just wanted to put an interesting thing here. My notebook name is Jerry so I was used Jerry\administrator first if the condition but running the workflow gets it completed. I change the condition and tried with Jerry\System but same result but actually my current User is System Account. I tried it with a local user e.g. Jerry\yasir and workflow completed successfully. What is the reason ? Does modified by stored user name instead of Login name :)

# re: Porting a SharePoint Designer (SPD) Workflow to Visual Studio.Net – Part 1 3/25/2008 9:09 AM Michael Blumenthal

Please post the rest of this topic as soon as possible!
My SharePoint Blog:

Comments on this post are closed.
Protected by Clearscreen.SharpHIPEnter the code you see: