Scriptable Reports

Communicating Between Controls

There are many possible ways to communicate between controls. This is not a complete list, just a few options.
1. Directly between control instances
For a custom control, getControlByName returns a CustomControl interface which is the public interface supported by all custom controls (the blue box in the diagram). To obtain a reference to the instance created from your module (the dark gray box in the diagram), use the instance property.
oControlHost.page.getControlByName( "Control1" ).instance.done(
    function( oModuleInstance )
    {
        // The module instance is available here so you can call your own methods.
        oModuleInstance.methodDefinedInYourModule();
    } );
2. Between control instances through the module
Since the modules remain loaded for the lifetime of the report, variables defined at the module scope are accessible by all instances of the control.
define( function() {
"use strict";
var variableSharedBetweenInstances = null;

...
3. Through a page module
Similar to #2. The page module (which can be added to all pages) can be accessed by all custom controls to share state, even across pages since the page module also remains loaded for the lifetime of the report.
oControlHost.page.pageModuleInstance.done(
    function( oModuleInstance )
    {
        // The module instance is available here
    } );
4. Session Storage
Browsers support sessionStorage which can be used to store and share state between controls.