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()
{
super();
QueryBuildDataSource productCategory_ds = this.query().dataSourceTable(tableNum(Al0VendorSearchCriteria));
this.query().dataSourceTable(tableNum(Al0VendorSearchCriteria)).clearRanges();
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));
}
}
}