Adding Script

If the user decision making and conditional decision making is not enough, you can also add script to any stage. This script will be executed once the stage is complete. You can add a script from the workflow designer by clicking the script icon on a stage, or clicking the stage title and then click "Script" in the hamburger icon:

Scripts can be used to make certain calculations or decisions that are hard to describe in the flowchart design. They can also be used to start secondary, parallel workflows by creating records in other parts of the database that have workflow associated with them.

From DbfScript, you can also use the special workflow command SetWorkflowStage(record, workflowName, stage), to update a record to be a specific workflow stage. You specify the name of the workflow in workflowName and the stage stage name in stage. This command also allows you to start a new workflow at a specific stage, if you don't want the workflow to start at the beginning, and also lets you revert a workflow to a specific stage or to switch to a different branch of the workflow.

In the script, the following variables are preset and available for use:


The #rec variable holds the current record associated with this stage. It can be modified and then updated in the database using the save command. Your script should not assign a different value to #rec.


The #input variable holds the values in the input form for that workflow stage.


The &path variable holds the path to the current location in the database.


The #user variable holds the record of the current user. This can be useful to look up user-specific data.

Another area to add scripts is in the Prepare drilldown. To get to this, you'll need to click on the stage to bring up the stage record, then go to the hamburger and select "Prepare Script". This allows a prepare script to be defined that will setup the workflow stage's form before it is displayed, by setting default values for each field. The script can update the #input variable with the different values, and end with 'return #input' to return the record for displaying.

For more information on DbfScript, see DbfScript Reference