Creating Custom Events that Execute Sub-Queries

A custom event is an event in which sub-queries are launched. Events need not be launched from primary queries. For example, you can execute a sub-query when an item is selected from a drop-down list, or a button is clicked, or where a complex calculation is included in the code. The event is defined, and, when the component receives the event, the component executes the nominated sub-queries by using values from the nominated Limit Lookup Table as query limits.

*  To define and test a custom event:

  1. In Interactive Reporting Studio , open a dashboard that contains the Conditional Sub-Queries component.

  2. Build a results or table section that contains columns to be used as filters for the sub-queries.

    This is the Limit Lookup Table.

  3. Build one or more queries to be launched when the custom event occurs.

    The queries are later designated as sub-queries.

  4. Create filters within each sub-query by using columns in the Limit Lookup Table.

    When the Conditional Sub-Queries component processes the sub-query, values are transferred from the Limit Lookup Table into the sub-query as filters.

    A column in the Limit Lookup Table may have no equivalent filter in a sub-query. This scenario is possible if two or more sub-queries are present. In this case, there is no need to add the filter to the sub-query. The component does not apply the missing filter when it executes the sub-query.

  5. Link the sub-queries and the Limit Lookup Table to the custom event.

    1. Open the Interactive Reporting Studio document and navigate to Conditional Sub-Query Properties.

    2. From Sub-Query Properties, select Add Custom Event.

    3. In the text box, enter the custom event name, and click Add.

      The custom event is added to Event Name.

    4. In Sub-Query Properties, define the action that the component must perform when the custom event is processed.

    5. From Event Name, select the custom event added in step c.

      The component loads the sub-query. It displays the Limit Lookup Table from which the sub-query obtains the filter values. As it is the first time the custom event is defined, the items are blank.

    6. From Limit Lookup Table, select the results or table that contains values to be used to filter the sub-query.

    7. Move selected sub-queries to be launched when the component receives the custom event, between Available Queries and Sub-Queries by clicking Next button and Back button.

    8. Click Apply.

  6. In the document, add JavaScript to the event.

    For example, in a button handler OnClick(), or drop-down list handler OnSelection(), or in the code enter this JavaScript:

    if (ActiveDocument.Hysl_csq) {
       Hysl_csq.Hysl_doSubQuery("<My Event Name>")
    }
  7. To test, run the event.

    The Conditional Sub-Queries component executes the nominated sub-queries.