When you want your code to act on GE field value changes, but are not writing a GE Plug-In, you need to register for notifications when a field value changes. (If you are writing a GE plugin, you can simply override the set() method.)
There is an example in the Layout Control template JavaScript.
Step-by-step guide
- Obtain the GE you're interested in. Generally this will be a GE that already exists; you don't actually want to get a new GE object. If you don't know how to access the GE from the current code location, place a breakpoint and explore the data available to you. You may also want to read:
- Getting the GE behind a Form Template Layout.
- Getting the GE behind a Form Component.
- Define your callback function. This function will receive two arguments, paramData and eventData.
- paramData is an object containing:
- GE: the GE object on which the value changed
- param: any extra information the event caller wanted to pass along
- eventData is an object containing:
- field: the name of the field that changed
- value: the new value of the field
Since you will call this function every time any field value on the GE changes, you'll need some extra logic inside to call the correct function for each field. For most cases, you probably won't want to do anything at all. We generally handle this by switching on the lower-cased value of the field name.
For example, if we wanted to do something each time a Person GE's FirstName field changed, we would define a function like this:function _geFieldValueChanged(paramData, eventData) { try { switch(eventData.field.toLowerCase()) { case "firstname": // call a function to do on-first-name-changed logic break; default: // for most fields, do nothing break; } } catch (ex) { Aptify.framework.exceptionManager.publish(ex); } }
- paramData is an object containing:
Call the GE's registerNotifications() function, providing the GEFieldValueChanged notification and your callback function:
ge.registerNotification({ event: Aptify.framework.configuration.eventDefinitions.GEFieldValueChanged, callBack: _geFieldValueChanged });
Related articles
Filter by label
There are no items with the selected labels at this time.