35. Work Flow
WorkFlow
Traditional WOW development easily handles operations such as data lookups, edits, deletes, and provides
some "work flow" via associated operations. More complex applications require real "work flow". Work flow is
the logical transition through a number of screens. The sequence of screens could lead to some composite
transaction at the end of the process. An example would be an application that enables making an airline
reservation.
To enable this capability, two new features have been created:
Global Variables
Variables that can be created and shared throughout a user's session. Global variables are established and
created by setting the field descriptor's UsageId to -3. When WOW processes an associated selection, insert,
update, or delete of a row, any fields present that are marked as Global are set in the user's session and
available to other operations. Other operations may reference those global variables using "??!" followed by the
field name (e.g. ??!orderNum). Global variables remain in effect until a row containing that variable is selected,
updated, inserted, or deleted and the new row field values override the previous values. Global values can also
be references in another field descriptor's default value.
Once a global variable is set, you can use it in SQL: SELECT * from X.Y WHERE Field1 = ??!YourFieldName
- Setting Global Variables & Defaulting Param. Values
- Row, User, Global Variables, and Usage ID
Next Operation
WOW operations now have a field called "Next Operation" which allows the selection of another operation to
execute when the current operation completes. The current operation completes when a row is inserted,
updated, or deleted. At that time, the next operation is executed. The next operation may, in turn, have a
next operation specified, thus enabling a complete flow of an application without the need to manually program.
Example 1
A common business scenario involves creating orders by first inserting an order header such as customer name,
order number, address, date, etc. Upon completion of the order header record, the user is then allowed to enter
order detail records.
In this example, the WOW developer would specify the order number (in the order header) as a global variable by
setting its field descriptor to –3. Assuming both order header and order detail files have an order number field,
the order number field (in the order detail file) would have its field descriptor's default value set to "??!OrderNumber"
where OrderNumber is the field in the order header file. When each order detail record is created, its order number is
automatically set to the value in the order header (which is the global variable set in the current session). This allows
the complete ordering process to be carried out cohesively. Each new order would get a new order number and each
order detail would be tied to its order header.
Example 2
Another common scenario for the work flow feature is a confirmation page. For instance, if an end user inserts a bug
report record, it may be desired to show a confirmation page assuring the user that his entry has been accepted and
will be acted upon. In this case, mark any fields in the bug report's field descriptors as global by setting the UsageId
to –3. Create a HTML code operation that includes confirmation text as well as the desired global variables.
For example:
"Your bug report has been logged and the ID is: ??!problemNum"
Advanced Work Flow
Sometimes, more complicated work flow scenarios may require programmatic control in terms of what the next completed operation should be. For example, an international flight reservation may require a different sequence of steps (operations) then a domestic flight. Or, if an insurance quote is inserted and it is more than 10,000,000 then it requires additional info, etc. To accommodate these advanced work flow needs, the WOW Java based framework can be overridden allowing you to control the exact flow. For more information, see the section on work flow in the WOW Programmer's Guide.
Multi-value Global Variables
There are times where it may be required for a drill down operation to remember multiple values selected from an earlier operation’s search parameters. For example, if the top level (1st) operation has SQL similar to this:
SELECT * FROM MySchema.MyTable WHERE city in ?
If the user selects more than 1 value for city before clicking on search, the results of the 1st report contain a link to drill down to operation 2. On the 2nd operation, we may want to retain the use of all of those selected city values from operation 1. The SQL to globally use those values may look like the following:
Select * FROM MySchema.MyTable2 WHERE (city in ??!city or ??!city is null)
Note: The Usage ID (in the Field Descriptor) must be set to -3 (Global) for field CITY (MySchema.MyTable1).
The above SQL tells WOW to plug in all of the global values for city (from operation 1), if any are selected. If no city choices are selected, all records for MyTable will be displayed. If the user selects 2 cities (City1 and City2), then WOW would substitute in (‘City1’,’City2’).
Select * FROM MySchema.MyTable2 WHERE (city in (‘City1’,’City2’) or ??!city is null)