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

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 layout control function:
    Layout control objects have a function called getGEObject(). Any time you have access to the layout control object, you can simply call getGEObject() on it. If the GE has been loaded, it will be returned.

    var _ge = this.getGEObject(); 
    var _ftl = this;
    var _ge = _ftl.getGEObject();


  2. Retrieving the GE from eventData:
    Overrideable events on the form template layout receive an object. This object almost always includes a formTemplateLayout property that is the layout control itself, and may also include a geObject property. If the geObject property exists, you can use it directly. Otherwise, you can call getGEObject() on the formTemplateLayout property.

    // afterLoad() receives an object with the geObject property
    // This function is registered as overriding afterLoad()
    function _afterLoad(eventData) {
    	var _ge = eventData.geObject;
    	
    	// do work with the GE
    }
    // beforeLoad() receives an object with a formTemplateLayout property
    // This function is registered as overriding beforeLoad()
    function _beforeLoad(eventData) {
    	var _ftl = eventData.formTemplateLayout;
    	var _ge = _ftl.getGEObject();
    }

Related articles

Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.