General X++ Development

How do I filter a form datasource in X++?

Asked by Sunny Vasty· Aug 13, 2026· 1 answers

How do I filter a form datasource in X++?

SSunny Vasty75 reputation · answered Aug 13, 2026

Add a range to the datasource query and rerun the query.

X++
QueryBuildDataSource qbds = SalesTable_ds.queryBuildDataSource();

qbds.addRange(fieldNum(SalesTable, CustAccount))
    .value(queryValue('US-001'));

SalesTable_ds.executeQuery();

If the filter is changed more than once, find/update the existing range or clear it first. Otherwise you can end up with duplicate ranges that make the form look broken.