Remove added datasource to querybuildDataSource

Hi ,

In project list page form. I have filter control to filter the projects in the tree node.

So the top level being top and next level being middle and next level bottom.

I am looking to get display only the middle records in the list page. For this I have taken the datasource query and added two new datasources of projTable. As in below code.

parentProjTableDataSource = ProjTable_ds.query().dataSourceTable(tableNum(ProjTable)).addDataSource(tableNum(ProjTable));
parentProjTableDataSource.joinMode(JoinMode::ExistsJoin);
parentProjTableDataSource.addLink(fieldNum(ProjTable, ProjId),fieldNum(ProjTable, ParentId));
parentProjTableDataSource = ProjTable_ds.query().dataSourceTable(tableNum(ProjTable)).addDataSource(tableNum(ProjTable));
parentProjTableDataSource.joinMode(JoinMode::ExistsJoin);
parentProjTableDataSource.addLink(fieldNum(ProjTable, ParentId),fieldNum(ProjTable, ProjId));

ProjTable_ds.executeQuery();

The execute query method runs fine and give me the correct data.

But after execution I want to revert back the query to its standard state removing above added datasources.

When I use parentProjTableDataSource.enabled(false);, it will disable one datasource but still i have one left in the query.

Please help.

The above code is in the form filter control modified method

I see that your code assign two different data sources to parentProjTableDataSource variable. The latter assignment overwrite the previously assigned value, therefore you end up with any reference to the first data source. The obvious solution is using two variables. Nevertheless you have more options - for example, you could name your data sources and retrieve them from the query by name (Query.dataSourceName()), use the occurrence parameter in Query.dataSourceTable() and so on.

(Question moved to the Developer forum.)

Thanks Martin,

It is resolved now.