Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  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:

    Code Block
    languagejs
    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:

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

...