Edit

Before (windowRef)

A script handler you can implement to override standard MoneyWorks behaviour.

Automatically called:  When a window opens or when a new record is loaded in the window (when the user clicks the Next or Prev button). For list windows, this will be called when the user changes the view in the sidebar.

Use for:  To set the initial field values of a custom window; To perform any kind of setup your script needs to do for a standard window; For a list window, install Toolbar commands.

Specific Naming You can and should implement a Before handler that is specific to the particular window ID of interest. In the case of the Transaction entry window, the handler can also be specific to the 2-letter transaction type. If you do not uses a window ID-specific name, you must test the window ID returned from GetWindowID(windowRef). A non-specific before handler would be called for every Window.

e.g. Before:<WindowId>:<TransactionType>

Example 1: 

on Before:F_TRANS:DI(windowRef) // only called when a Debtor Invoice is loaded into a transaction window
    if GetFieldValue(windowRef, -2) = 0
        Navigator("", "This is a new invoice")
        // do something that is actually more useful for new invoices...
    endif
end

Example 2: 

on MySum
    let s = SumSelection("transaction.Gross - AmtPaid", "*highlight")
    Alert("Outstanding Total = " + s)
end

on Before:F_TRANSLIST(windowRef)
    InstallToolbarIcon(windowRef, "MySum") // Install toolbar icon in list
end