forge

Renaming the Default Workflow with the ECM Starter Kit B2TR

I’m about neck deep with Visual Studio 2005 and SharePoint workflow right now.  (Actually, I’m breathing through a straw as you may see.)

The 2007 Office System Starter Kit: Enterprise Content Management Starter Kit (ECMsk) has in it some Visual Studio project templates to get you started with using SharePoint and Workflow together.  However, it’s in beta so it’s not perfect…

The first issue isn’t that bad, it adds a reference to Microsoft.Office.Workflow.Tasks – which isn’t installed with WSSv3 – even with Office 2007 Pro and InfoPath 2007  installed.  It means removing the reference and the using line ‘using Microsoft.Office.Workflow.Utility’ in the workflow1.cs file.   Not that big a deal all things considered.

Help Your SharePoint User

The other problem is a bit more tangled.  That is you can’t easily rename the workflow to be something else.  If you try renaming the workflow you’ll get a friendly prompt from Visual Studio stating “You are renaming a file.  Would you also like to perform a rename in this project of all references to the code element ‘Workflow1’?”  It’s pretty nice of it to ask so sure.  Click the Yes button.  This is where you have your first signs it’s going to be ugly.  Visual Studio’s next dialog states: “Your project or one of its dependencies does not currently build.  References may not be updated.  Continue: Perform the refactoring, Preview: Show a preview of the references that will be updated, Cancel: Cancel the refactoring” followed by a helpful “Show this dialog every time” checkbox and the option to continue, preview, or cancel.  You can click continue, but it’s right.  Not all the references were updated.

If you open the newworkflowname.designer.cs (*.designer.cs) file for the workflow you’ll find a section of code marked “do not touch” – said only in a slightly nicer way.  In that section you’ll find an InitializeComponent() method.  It contains four references to the old workflow1 (and a comment) – all in text references.  A quick search and replace and the rename will be complete.  However, there’s one little catch.  You must have the Design view of the newworkflowname.cs file (*.cs [Design]) closed in order for your changes to be recorded.  Make sure you do that before the search and replace.  Do a save then a Ctrl-Shift-B to build and see if it builds for you.

Easy as pie, right?