Skip to content

November 26, 2006

Adding the second workflow to a SharePoint Workflow Assembly

With the  2007 Office System: Enterprise Content Management Starter Kit (ECMsk), you get a project type that will create a SharePoint aware workflow (in either sequential or state machine format.)  However, if you want more than one SharePoint workflow in the same assembly you’ve got a problem.  The ECMsk (at least in Beta2TR which is the latest publicly available version as of this writing) doesn’t add the project item type into Visual Studio so you can’t create a second workflow easily.  Great.  Here’s how to do it by hand.

  1. Create a workflow of your choice.  Choose the option indicated (code) not the one indicated (with code separation).  [Note: I used sequential workflow for my example – and technically this should be possible with code separation I just didn’t test the steps, yet.]
  2. Open the code view of your new workflow (*.cs)
  3. Add a using statements to the top of the file, after the existing using statements
  4. using Microsoft.SharePoint
  5. using Microsoft.SharePoint.Workflow
  6. using Microsoft.SharePoint.WorkflowActions
  7. Change the class to derive from SharePointSequentialWorkflowActivity instead of SequentialWorkflowActivity.
  8. Save your work and close the file.
  9. Open the design view of the workflow(*.cs [Design])
  10. Drop the onWorkflowActivated activity on the workflow surface.
  11. Double click on the onWorkflowActivated activity to create the invoked code behind.
  12. Save the file and then close the design view (*.cs [Design])
  13. Open the designer.cs file for the workflow (*.designer.cs) (It’s stacked underneath the *.cs file of the workflow by default.)
  14. Add a using statement to the top of the file after the existing using statements
  15. using Microsoft.SharePoint.Workflow;
  16. Add two variable declarations above the onWorkflowActivated1 definition
  17. public Guid workflowId = default(System.Guid);
  18. public SPWorkflowActivationProperties workflowProperties = new SPWorkflowActivationProperties();
  19. Expand the “Designer generated code” segment.
  20. After the line in InitializeComponent() which reads “this.CanModifyActivities = true;” add the following:
  21. System.Workflow.ComponentModel.ActivityBind activitybind2 = new System.Workflow.ComponentModel.ActivityBind();
  22. System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
  23. activitybind2.Name = “myWorkflowName”;
  24. activitybind2.Path = “workflowId”;
  25. activitybind1.Name = “myWorkflowName”;
  26. activitybind1.Path = “workflowProperties”
  27. After the line in InitializeComponent() which reads “this.onWorkflowActivated1.Invoked += new System.EventHandler(this.onWorkflowActivated1_Invoked) add the following:
  28. this.onWorkflowActivated1.SetBinding(Microsoft.SharePoint.WorkflowActions.OnWorkflowActivated.WorkflowIdProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind2)));
  29. this.onWorkflowActivated1.SetBinding(Microsoft.SharePoint.WorkflowActions.OnWorkflowActivated.WorkflowPropertiesProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind1)));
  30. Save the *.designer.cs file.
  31. Open the design view of the workflow (*.cs [Design])
  32. Click on the CorrelationToken property and type ‘workflowToken’.
  33. Expand CorrelationToken and in the OwnerActivityName that appears beneath it select the name of your workflow.
  34. Save the file.
  35. You’re ready to build.  Press Ctrl-Shift-B to build – and your new workflow should just work.

Not as simple as it should be – and I have no way of knowing if this is a supported (or supportable) way of getting a standard workflow to work as a SharePoint workflow – but it’s worked thus far in my testing.

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.

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?

Connect the Dots: Developing Products

Let me start in a rather odd way.  I don’t have all the answers about developing products.  Frankly, I probably have only the slightest sliver of understanding of what is needed to develop products.  Having been stuck at the phase where I have completed products that I haven’t been able to release to the market – I’m focused on thinking about the problem and trying to find solutions.

My son is at the stage where he likes dot-to-dot puzzles.  He connects each dot not knowing what the end result will be.  He carefully connects one dot and then the next and then the next and doesn’t take the time to step back until he’s completed.

It strikes me that this isn’t much different than the process of creating a product.  I realize that there are lots of dots – most of which need to be connected – to make the complete picture – the product.  I’m sure (because I’ve not managed to make my product sales what I would call successful) that I’m missing a few, but I wanted to share what I’ve figured out thus far.

Developing the Product

Perhaps the easiest part of the process for me is developing the solution.  I’ve spent the last 15 years of my professional career creating solutions for clients.  Writing the program and understanding how to make it reusable isn’t something I really struggle with any more.  If you look in my source control system you’ll find dozens of testing harnesses and tools designed to perform reusable operations – and that doesn’t even include the things that I’ve packaged to be products.


Also in the easy category for me is writing.  I’ve spent the last several years writing articles and books.  Writing isn’t something I dread (very often).  It’s just another thing to do.  Once I have working and tested code, it’s off to write some documentation that will help people understand how to use it.  The trick here, if there is one, is writing the documentation to spark the user’s creativity on how the tool can solve problems other than the one it was intended to solve.

Installation Package

Ouch.  This one hurts.  Every experience I have had making anything but the most trivial installation package has ended in disaster.  However, a good solution to the need to get the software installed is an essential part of the overall solution.  I bias strongly towards programs that require little or no installation – but that’s honestly because my experience with installers has been so bad.


Somewhere in this process you have to integrate a licensing engine.  As much as I hate to say it software piracy runs rampant in the world.  People don’t quite understand the intellectual property which is wrapped up in the software and the need to compensate the author for that intellectual property.  I like to ignore this but I’m painfully reminded by my friends and colleagues that I cannot.

Store Front

I learned that in the publishing world there’s not a lot that matters other than shelf space.  Good authors, good books, and good ideas have died a slow death because they were never provided the shelf space in the book stores that they required.  A product is the same way.  The product needs a home.  It needs a place for people to come to find it.  It needs a place that describes it and explains how it works, what the values are, and the cost.  Without this place no one will know the product exists – or they won’t be able to find it if they do know it exists – and you won’t get any sales.

By the way, this is the point where I’m stuck.  I, in part, build commercial grade eCommerce solutions for large organizations.  My threshold for the system to deliver my products is really, really high.  That means that some of the traditional options for Micro-ISVs just don’t just make me feel comfortable presenting my solutions there.  I haven’t yet invested the time to get my platform up and running personally… so I am stuck.

Commerce Enabled

Once you have a store front and people have a way to know that they want to buy the solution, it’s important that you have a way to take their money.  Honestly, this part has become much simpler over the last few years.  With credit card processors owned by large banks now supporting web service calls to authorize transactions, and the services offered by PayPal, there are real options for conducting commerce over the web.  Credit Cards are not quite universal; however, they are pervasive enough that they are an effective payment mechanism.  The real challenges here are managing fraud and dealing with “returns.”


Supporting a product once it’s in the market is critical to long term success, but how does a small software vendor cope with the time that supporting customers requires?  Support is one part about preparing – so you can track defects, customer satisfaction, etc., but more than anything else it is about creating and preserving timely communications with the users trying to use the product.  Not an easy task for most organizations.  Perhaps this is why so many software companies struggle with support today.


Build it and they will come doesn’t work.  You need to let people know that your product exists.  For most folks this means buying advertising.  It is money out of your pocket to get people to look at, think about, and perhaps even evaluate your product.  The folks that I know who are successful at selling products all talk about how their advertising relates to product sales.  They don’t see a one-to-one relationship – but they definitely see an impact on sales.  So your product (and perhaps your company) needs some sort of a marketing strategy.


The final part of developing a product is developing a lifecycle for the product.  What will the next version of the product do?  When will you make the investment in the next version of the product?  Planning for the next revision is as much a part of the total solution as any other part of the process.


I don’t know what all of these dots make when connected.  I’m pretty sure it’s not a bunny rabbit, but beyond that I haven’t a clue what to expect.  When you’re looking at putting together a product ask yourself if you can connect all of these dots – or not.

Recent Posts

Public Speaking