Events in forms and grids in model-driven apps
You can associate event handlers to only some events using the UI. For events that are not available to be associated through UI, Client API provides methods that can be used to attach event handlers to such events.
Add or remove event handler function to event using UI
Use the Event Handlers section of the Form Properties dialog box to associate your script with an event for forms and fields.
Add or remove event handler function to event using code
Using the following methods to add and remove event handler for events that cannot be associated through UI:
|Attribute OnChange||addOnChange and removeOnChange methods|
|Form OnLoad||formContext.ui addOnLoad and removeOnLoad methods|
|Form data OnLoad||formContext.data addOnLoad and removeOnLoad methods|
|Form OnSave||addOnSave and removeOnSave methods|
|Lookup control PreSearch||addPreSearch and removePreSearch methods|
|kbsearch control OnResultOpened||addOnResultOpened and removeOnResultOpened methods|
|kbsearch control OnSelection||addOnSelection and removeOnSelection methods|
|kbsearch control PostSearch||addOnPostSearch and removeOnPostSearch methods|
The execution context is automatically passed as the first parameter to functions that are set using the code. More information: Client API execution context
Form event pipeline
You can define up to 50 event handlers for each event. Each event handler is executed in the order that it is displayed in the Event Handlers section in the Events tab of the Form Properties dialog box.
Use the setSharedVariable and getSharedVariable methods to pass a common variable between event handlers (functions). Use the execution context getDepth method to know the sequence that an event handler is being executed in relative to other event handlers.