Error message: "Failed to execute query because no root data source on the form matches the root data source on the query."
I have this problem when I want to test joining 2 data sources by X code.
My form looks simple, just 2 data sources (SaLesTable, SalesLine) with default properties

The code below is from SalesLine:init data source.
public void init()
{
Query q;
QueryBuildDataSource qBSalesTable;
QueryBuildDataSource qBSalesLine;
super();
q = new Query();
qBSalesTable = q.addDataSource(tablenum(SalesTable));
qBSalesLine = qBSalesTable.addDataSource(tablenum(SalesLine));
qBSalesLine.addLink(fieldnum(SalesTable,SalesId),fieldnum(SalesLine,SalesId));
qBSalesLine.joinMode(JoinMode::InnerJoin);
qBSalesLine.addRange(fieldnum(SalesTable,SalesId)).value("001*");
info(q.toString());
this.query(q);
}
Anyone know why I have such an error?
Infolog:
