You are here: Scripting Reference > Events

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

ClosedDataset LinkedData
ClosedDataset OnStartMap
ClosedDataset BeforeMap
ClosedDataset AfterMap
ClosedDataset AfterDetailMap
ClosedDataset OnEndMap

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.

ClosedField BeforeMap
ClosedField OnMap
ClosedField AfterMap

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 See "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              
               

 

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.