Validate (windowRef)

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

Automatically called:  When the user clicks OK or Next on a record that has had changes made to it (if no fields have been changed, the handler may not be called). Use the windowRef to access information from the window.

Use for:  To control whether the data in the window can be saved as-is. The handler should return 1 (true) or 0 (false) to indicate whether the window content should be accepted. Returning 0 will prevent the window from closing. IMPORTANT: If you do this you should provide an explanation to the user via an alert or coachtip. Users will be very unhappy if they don't know why the OK button is not working!

Specific Naming You can and should implement a Validate 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 use a window ID-specific name, you must test the window ID returned from GetWindowID(windowRef)


on Validate:F_TRANS:DI(windowRef) // only called to validate Debtor Invoice transaction window
    if GetFieldValue(windowRef, "E_DEPT") = ""
        Alert("Salesperson must be specified")
        return false

Return value:  Boolean. TRUE indicates that the contents of the window are valid and acceptable and the record can be saved. An After message will follow. FALSE indicates that the contents of the window are unacceptable and the record will not be saved and the window will not close. An After message will not follow.