Appearance
Events
Events are points at which script code can be entered by the user.
The Flow scripting engine is an event based engine. The engine executes the events in a predetermined order, executing the scripts that are attached to the events by the user. The table at the bottom of this page illustrates the execution order for events. An event is ignored if there is no script attached to it.
The events are provided against the destination data definition of the map. Each dataset and its fields have events which a user can attach script to. The engine executes based on this destination data definition, running through its datasets and fields executing the events. This happens in a predetermined order however it is possible for the user to control this order of execution with special functions in the script.
There are different events for both datasets and fields
Dataset Events
Dataset LinkedData
This is a special event that sets the source dataset. If LinkedData is not set the dataset will only process once, however if LinkedData is set to a source dataset then the engine will repeat the processing of the dataset until it reaches the end of the source dataset. If there are 10 records in the source, then the dataset will process 10 times and end up containing 10 records.
Dataset OnStartMap
This event fires once each time the engine starts processing the dataset. If the dataset has Linked Data it will only fire once at the start of the first record in the source dataset. However if the dataset is a child of another dataset the engine will start its processing multiple times (once for each record in the parent dataset) therefore this event will fire once each time the dataset starts.
Dataset BeforeMap
This event fires once before each record is processed. If LinkedData is set then multiple records could be processed and this will fire once before each of those records. If LinkedData is not set then this will only fire once. After this event each field of the dataset is processed. For more information on its usage refer to Dataset BeforeMap event
Dataset AfterMap
This event fires once after each record is processed (that is after the fields of the dataset are processed). If LinkedData is set then multiple records could be processed and this will fire once after each of those records. If LinkedData is not set then this will only fire once.
Dataset AfterDetailMap
This event will fire for a parent record after any child datasets have been processed. If this parent dataset has multiple records then it will fire once after each record's child datasets are processed.
Dataset OnEndMap
This event fires once each time the engine finishes processing the dataset. If the dataset has Linked Data it will only fire once at the end of the last record in the source dataset. However if the dataset is a child of another dataset the engine will finish its processing multiple times (once for each record in the parent dataset) therefore this event will fire once each time the dataset ends.
Field Events
In essence only the OnMap event is needed on each field, however a BeforeMap and AfterMap event is provided in cases where you want to split up the script into sections.
Field BeforeMap
This event fires first for the field.
Field OnMap
This is the main event for the field and is normally where your script is attached.
Field AfterMap
This event fires last for the field.
Attaching a script to an event
You can attach a script to an event by selecting the event and then clicking in the script editor area of the screen. A skeleton of the event will display and you can enter you script. Edit the script by selecting the event. The script code will display in the script editor area of the screen.
Automatically creating script on events
Certain events can have scripts created automatically by drag and drop. However drag and drop will have no effect if the event already has a script attached. In this case you will need to edit the event by selecting it, or remove the event's script and perform the drag and drop again.
LinkedData events can be set by dragging a dataset from the source and dropping it on the destination dataset. You will see the script appear in the script editor area of the screen. OnMap events for fields can be set by dragging a field from the source and dropping it on the destination field.
Removing a script from an event
Right click the event and select the Clear option
Event Execution
Events are fired in a predetermined order. With Program Flow in mind the Events are fired in the following loop (for a two-level hierarchy of datasets: parent, child). The highlighted Events are those that are most commonly used.
| Parent dataset | Parent record | Parent field | Child dataset | Child record | Child field | ||
|---|---|---|---|---|---|---|---|
| OnStartMap | |||||||
| BeforeMap | |||||||
| BeforeMap | |||||||
| OnMap | |||||||
| AfterMap | |||||||
| (repeat) | |||||||
| AfterMap | |||||||
| OnStartMap | |||||||
| BeforeMap | |||||||
| BeforeMap | |||||||
| OnMap | |||||||
| AfterMap | |||||||
| (repeat) | |||||||
| AfterMap | |||||||
| (repeat) | |||||||
| OnEndMap | |||||||
| AfterDetailMap | |||||||
| (repeat) | |||||||
| OnEndMap | |||||||
TIP
LinkedData is a special event. If LinkedData is set the section between BeforeMap to AfterDetailMap is repeated for each record in the linked dataset. If LinkedData is not set then that section is executed once.
For more information about the specific events and their usage refer to the following topics.