Filtering Rows in a Standard Query Facet

This document provides information on how to filter rows in a standard Query facet.

The process described below demonstrates how to use a standard Query facet as the basis for an enhanced Query facet that can filter the data contained in the rows:

  1. Link the "lookup" for one or more properties to a standard representation class.
    Refer to Modifying the selections (Query facet) for a standard data table.
    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 for complex filters.
  2. In the Scripts block of the General tab, add script [data type code]_RSTD. Make sure you choose the appropriate script code that uses "AQUERY…" events to extend the filter criteria (AQUERY_CRITERIA_AFTER) and amend and/or populate each row values. For example:
    $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 your representation class before it can be used in Sage X3. It should validate:
    • The associated data class.
    • Any child classes of the associated data class.
    • The representation class.
  4. Click Options > Global validation on the right-hand panel of the representation class to perform a global validation.

Completed result

  • The property will allow selection of a value using the magnifying glass displayed in the field.
  • The script will call the column values.
  • The Query facet displayed when selecting the magnifying glass is the standard display for the original data type. Rows in the Query facet are filtered to only display those that contain the value defined in the script.