How to filter rows in a standard query facet

See also: How to modify the selections (Query facet) for a standard data table.
This document describes how to use a standard Query facet as the basis for an enhanced Query facet.

This ‘How-to’ provides information on how to filter the rows in a standard Query facet.

The following development process demonstrates how to use a standard Query facet as the basis for an enhanced Query facet which includes filters on the data in the rows:

  1. Link the ‘lookup’ for one or more properties to a standard representation class.
    See How to modify the selections (Query facet) for a standard data table (Example 2).

    Note: A default filter can be added directly to the representation class. This should be considered when the filter condition is simple. Follow steps 2 and 3 below for complex filters.

  2. Add a code script to the representation class definition.

    General tab > Scripts block: Add the script [data type code]_RSTD with the appropriate script code which use "AQUERY…" events to extend the filter criteria (AQUERY_CRITERIA_AFTER) and to amend and/or populate each row’s values. For example:
    ``
    CODECODE CODE

    $METHODS
    Case CURPTH
    When ""
    Case ACTION
    When "AQUERY_CRITERIA_AFTER" : Gosub AQUERY_CRITERIA_AFTER
    Endcase
    Endcase
    Return

    $AQUERY_CRITERIA_AFTER
    If (PQRY.QWHERE <> "")
    PQRY.QWHERE = "(" + PQRY.QWHERE + ") and PROPERTY eq '" + VALUE + "'"
    Else
    PQRY.QWHERE = "PROPERTY eq '" + VALUE + "'"
    Endif
    Return
    ````

  3. Perform a global validation on the representation class.

    You must perform a global validation on your representation class before it can be used in Sage X3. A global validation will validate:

       Click Options > Global validation on the right panel of the representation class to perform        a global validation.

Completed result

The property will allow selection (magnifying glass is displayed in the field) of a value. The script will call the column values. The Query facet displayed when the magnifying glass is selected will be the standard display for the original data type with the rows in the Query facet filtered to only display those rows that contain the value defined in the script.