Thursday, November 10, 2005
Workflow Made Simple
I recently wanted to build myself a workflow program for configuring quotations for my business (Guinterface). What I really wanted was a "drag and drop" product configuration engine that interfaced with my payment processor (either PayTrust or 2Checkout). I also wanted it to have the ability to take a configured product and print out a pdf quotation (not everyone can pay you right away, some need authorization from their boss).
There really was nothing out there that met my needs (that was in my price range ... FREE). When faced with not having what I want or paying WAY to much for it I take the programming road. The first step in the configuration/quotation/shopping cart program is leading the user through a series of questions that determine what the product will cost. The obvious solution to that was some kind of graphical workflow. JGraphPad, is a "flowcharting" package that is much like Microsoft Visio (except that it is free and a darn sight more flexible). What makes this program great is that it outputs to XML and it allows you to define properties at the "nodes" of your graphs.
To create the front end to my workflow/configuration engine I utilized JGraphPad to create product configurations. To do this I created a few different node types (Workflow, Attributes and Coupon Nodes) and of course there are the arrows that connect Workflow nodes. The Workflow nodes are connected together to form the steps for configuring a product. Each Workflow node asks a question of the user and then exits to another Workflow node via a arrow (based on user input). The Attribute nodes are simply the questions that we want to ask to the user. An example of the properties of a Workflow node is:
This nodes properties basically asks the workflow engine to ask the Attr_BaseInstalls (from the Attribute node of the same name) question. The number of unites that will appear on a quotation for this line is in (evaluated Perl) in the StepLineUnitQty field. The coupons that can be applied to this step are in the CouponsThatApply attribute. The title shown on the web form that asks the Attr_BaseInstalls question is in the StepTitle attribute. The description for quotation line is in the StepLineDesc in evaluated Perl. The currency value that will appear on a quotation for this line is in (evaluated Perl) in the StepLineValue field in evaluated Perl.
The properties for the Attr_BaseInstalls Attribute node are as follows:
This defines all the properties of the questions we ask the user from the Workflow Nodes. It encapsulates checking of user input (Verification property), user prompts (Display Prompt), etc.
Once I had created a structure for creating these workflows I needed a way to interpret the results and lead the user through a list of questions to configure their products. Since JGraph graphs are saved as XML data I was able to use Perl (with the XML::Simple and Graph::Directed modules) to interpret the JGraphPad save files and create the rest of the configuration engine. The final result looks something like:
I love using a combination of open source software with programming know how to solve problems (rather than spending hundreds of dollars). My product configuration/workflow engine may not be pretty but it sure is free ;-).