The FormEvent object is a top-level, predefined MetaScript object. You can automatically access it without using a constructor or calling a method.
Description
The FormEvent object is designed to allow event listeners in MetaScript 2.x to access the events that caused them to be executed. The top-level FormEvent object always refers to the most recent event fired for the form.
Form events are distinct from form control events: each form control event is local to a particular form control, while form events represent events that affect the entire form (for example, the loading of a Virtual Ticket object for display in the form). For information on handling form control events, refer to the description of the Event object.
Property Summary
Property
Description
targetName
A read-only property that represents the name of the changed field for "elementChanged" events. Currently not used with other event types.
type
A read-only property that represents the event type, see Event Types.
The document's properties have been changed using the Properties window.
Attach / Modify
"attach"
yes
"modify"
yes
Templates
"newTemplate"
yes
"loadTemplate"
yes
"templateLoaded"
yes
"editTemplate"
yes
"saveTemplate"
yes
"meta_templateSaved"
Event Sequences
Form.object property is re-assigned a new FormObject instance before dispatching any event that witnesses Form.objectState's transition from "none" to "new" or "existing" state.
Creation of a new object (New button)
Event.type
Form.mode
Form.objectState
Event.cancelable
Notes
↪
"loadForm"
"none"
"none"
false
↪
"newObject"
"none"
"none"
true
↪
"objectSet"
"show"
"new"
false
↪
"editingStarted"
"edit"
"new"
false
Changing properties of a new object (Properties button, object is not added to the database yet)
Event.type
Form.mode
Form.objectState
Event.cancelable
Notes
↪
"propertiesChanged"
"edit"
"new"
false
Adding newly created object to the database (Add button)
The following code illustrates the use of the FormEvent.type property in an event listener:
Handling "elementChanged" event
If the below code is added into the Global MetaScript for a form, an alert will appear if the "Job Name" field is changed when a Job document is edited using that form.