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

Get the GE behind a Form Component

When working in the code of a form component, you may need access to the GE being displayed by the form component.

Unlike the Aptify .NET API, the Aptify JavaScript API does not require the developer to manage the communication between the GE and the UI. If you change a GE field value, that value will change in the UI, and vice versa.

This can make it very tempting to implement business logic in a form template layout control. Resist this temptation. Any logic that is not directly dealing with the UI is business logic and should be implemented as such in a client-side GE plugin.

Step-by-step guide

  1. Retrieving the GE from the main form component function:
    Form component objects have a function called getGEObject(), which retrieves the GE object behind the form template hosting the component. Any time you have access to the form component object, you can simply call getGEObject() on it. If the GE has been loaded, it will be returned.

    Directly reference the "this" variable
    var _ge = this.getGEObject(); 
    Reference an aliased "this" variable
    var _ctrl = this;
    var _ge = _ctrl.getGEObject();
  2. Retrieving the GE from eventData:
    Overrideable functions on the form component usually do not receive any information about the form component itself. It's best practice to define a variable to reference the control in the main form component function, as in the second example above. (Remember, in JavaScript the this keyword is the calling context, which is not always the same as the object where you defined the function.)

    Reference the GE through a higher-scoped variable
    // refresh() receives the domElement of the control
    // This function overrides refresh()
    // We assume we have previously defined _ctrl as the form component object, 
    // as in the second example above
    function _refresh(domElement) {
    	var _ge = _ctrl.getGEObject();
    }

Copyright © 2014-2019 Aptify - Confidential and Proprietary