KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Avoid using deprecated form event commands
PRODUCT: 4D | VERSION: 11 | PLATFORM: Mac & Win
Published On: June 16, 2010

The following form event commands have been deprecated yet are kept for compatibility reasons:


Starting with version 6, you should consider using the Form Event command and checking if a corresponding event occurs:

The depracated form event commands would return True in specific situations. This was then used in Case of and If statements like the following example:

If(Activated)
    ORDER RECORDS BY([Parents];[Parents]Children;>)
    ` ...
End If


The Form event command is used in a similar way, however it uses a constant for the specific event as a parameter like the following example:

If(Form event=On Activate)
    ORDER RECORDS BY([Parents];[Parents]Children;>)
    ` ...
End If


In both of the above examples, the code is only ran when the condition evalutated by the If statement returns True.

Here is a list of one-to-one matches for the depracated form event commands to the corresponding Form event constant:

CommandForm Event
DeactivatedOn Deactivate
ActivatedOn Activate
In HeaderOn Header
In Break On Printing Break
In FooterOn Printing Footer
AfterOn Validate


Two of the deprecated form event commands, Before and During, can return True for many form events in the new paradigm. See the table below for more information:


CommandForm Event
BeforeOn Load
On Display Detail
On Printing Detail
DuringOn Clicked
On Double Clicked
On Losing Focus
On Getting Focus
On Menu Selected
On Data Change
On Close Box
On Printing Detail
On Open Detail
On Close Detail


The following special syntax, that was used in older versions of 4D, can be easily achieved with one Form event constant:

Special SyntaxForm Event
(Before & During)On Display Detail


Using the Form event command gives the developer much more granul control over events then the older deprecated commands; however because of this added granularity, your code should be thoroughly tested when replacing these commands as some of the legacy code may need to be placed in different form events.

For more information please read up on the Form event command.