Executed before a query is run and the dataset is generated.

Visual Basic


The C/AL code of a query object includes the OnBeforeOpen trigger that you can use to change the data that will be included in the resulting dataset. For example, you can use the OnBeforeOpen trigger to apply filters to a column.

The OnBeforeOpen trigger only supports local variables; global variables are not supported.

A query cannot be run from the OnBeforeOpen trigger. You cannot call functions from the triggers that run the query, such as OPEN, SAVEASXML, READ, or CLOSE functions.


The following code applies a filter on the Quantity column of the query by calling the SETFILTER function on the OnBeforeOpen trigger of the query object.

Copy Code
currQuery.SETFILTER(Quantity, '>50');

See Also