I’ve recently learned that it’s possible and even fairly easy to create a state machine workflow using SharePoint Designer. Necessity is the mother of invention and all that good stuff and I had a need this week that looked for an invention. Coincidentally, I came across this MSDN forum post as well. My personal experience this week and that "independent confirmation" lends strength to my conviction. I plan to write about this at greater length with a full blown example, but here’s the gist of it:
- The approach leverages the fact that a workflow can change a list item, thereby triggering a new workflow. I’ve normally considered this to be a nuisance and even blogged about using semaphores to handle it.
- SharePoint allows multiple independent workflows to be active against a specific list item.
To configure it:
- Design your state machine (i.e., the states and how states transition from one to the next).
- Implement each state as separate workflow.
- Configure each of these state workflows to execute in response to any change in the list item.
Each state workflow follows this rough pattern:
- Upon initialization, determine whether it should really run by inspecting state information in the "current item". Abort if not.
- Do the work.
- Update the "current item" with new state information. This triggers an update to the current item and fires off all the state workflows.
Aside from the obvious benefit that one can create a declarative state machine workflow, all that state information is terrific for building KPIs and interesting views.
It does have a fairly substantial drawback — standard workflow history tracking is even more useless than normal 🙂 That’s easily remedied, however. Store all of your audit type information in a custom list. That’s probably a good idea even for vanilla sequential workflow, but that’s for another blog post 🙂
I call this a "mea culpa" because I have, unfortunately, said more than once on forums and elsewhere that one must use visual studio to create a state machine workflow. That simply isn’t true.
</end>