If you have a comment on this topic, contact Aptify Documentation. If you want to return to the Aptify Community Site, please click here.

Register for GE Field Value Change Notifications

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

  1. 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:
    1. Getting the GE behind a Form Template Layout
    2. Getting the GE behind a Form Component
  2. Define your callback function. This function will receive two arguments, paramData and eventData.
    1. paramData is an object containing: 
      1. GE: the GE object on which the value changed
      2. param: any extra information the event caller wanted to pass along
    2. eventData is an object containing:
      1. field: the name of the field that changed
      2. 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);
    	}
    }
  3. Call the GE's registerNotifications() function, providing the GEFieldValueChanged notification and your callback function:

    ge.registerNotification({
    	event: Aptify.framework.configuration.eventDefinitions.GEFieldValueChanged,
    	callBack: _geFieldValueChanged
    });

Copyright © 2014-2019 Aptify - Confidential and Proprietary