Skip to content

Customize QueryOpen

Patrick edited this page Nov 27, 2020 · 1 revision

This hook is called when you execute a query. The full query string is passed as a parameter. You cannot change the query here. If you want to do that, check CustomQuery for more info.

This hook is used in conjuction with global fields, like the global_domain field in QAD.

  /* Parse the query word by word and look for the domain field.
   * If the #QAD domain field is used in an equality match, filter 
   * out the value and save that as the new global_domain
   */
  DO iWord = 1 TO NUM-ENTRIES(pcQuery,' ') - 2:
    IF ENTRY(iWord,pcQuery,' ') MATCHES '*_domain'
      AND ENTRY(iWord + 1,pcQuery,' ') = '=' THEN
    DO:
      cValue = ENTRY(iWord + 2,pcQuery,' ').
      cValue = TRIM(cValue,'()"~'').
      IF cValue > '' THEN global_domain = cValue.
    END.
  END.
  */

For more information on this, please check GetFilterValue on how to use this with QAD or similar situations where you have a global field or company-field (a.k.a poor man's multi-tenancy)