AX – D365FO – Clear data source query ranges

If you add a query range with a certain value to a Query, then next time you execute the query with another value the query doesn’t clear previous range.

In order to clean the old values you have to use clearRanges() method

see example below

        /// </summary>
public void executeQuery()
            QueryBuildDataSource productCategory_ds = this.query().dataSourceTable(tableNum(Al0VendorSearchCriteria));

            int i = ActivityTree.getSelection();
            if(ActivityTree.getSelection() != 0)
                int64 currentNodeSelected = ActivityTree.getItem(ActivityTree.getSelection()).data();
                if(currentNodeSelected != 0)
                    productCategory_ds.addRange(FieldNum(Al0VendorSearchCriteria, VendorActivityRefRecId)).value(int642Str(currentNodeSelected));


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s