✏️ Explanatory Question
The executeQuery() method is a standard method of a form data source that runs the data source query and displays the retrieved records. You can apply a filter on the data source that uses a query by overriding executeQuery(). The main difference between this method and the init() method is that the init() method runs once during the opening of the form, whereas the executeQuery() method runs whenever the form is refreshed.
Example
You have a custom form with a table named TrainingMaster. The table has an enum type field named TrainingType that has two values: Online and Classroom. The data in the form should be filtered with the Trainingtype of Online only.
[DataSource]
class TrainingMaster
{
public void executeQuery()
{
QueryBuildDataSource queryBuildDataSource;
queryBuildDataSource =
this.query().dataSourceTable(tablenum(TrainingMaster));
queryBuildDataSource.clearRanges();
queryBuildDataSource.addRange(fieldnum(TrainingMaster,
TrainingType)).value(enum2Str(TrainingType::Online));
super();
}
}