Adding workflow to a table

In Polar Studio, the concept of 'workflow' is used to define several states a particular (single) record in a table can be in and the actions that exist to bring the record from one state to another.

Take for example an Order. For the happy-flow, this could be as follows. Initially, the Order is just created, so the status is now 'New'. When all OrderDetail lines are added, the customer can 'Order' the Order. Now the Order will be processed and the ordered producs will be delivered. Once delivery has taken place (and the invoice is sent) the customer is expected to pay for the Order. When the payment is received, the Order is registered as payed.

Maybe we also want to allow the customer to cancel the Order, thus we add an action 'Cancel' that is allowed while the Order is 'New' or 'Ordered'.

Graphically, this would look as follows:

In Polar Studio, a workflow like this can easily be implemented. What we need is a field in the 'Order' table that contains the status. We would normally use a VARCHAR(50) field for this

What you may want to know in the table is when the last state transition has taken place. You can add a DATETIME field for this. We usually call this field 'LastStateTransitionDateTime'.

Also keeping track of all actions is probably wanted. We provide a generic table with logic in our template projects (a table called 'WorkflowLog' together with a custom control 'WorlflowLog' that can be used to display the log on a form). Another way is using the built in feature of Polar Studio. This uses a TEXT/NTEXT field that will be filed with encoded text-lines for each action. When this field is displayed on a form, the last 10 lines will be decoded and shown.