In executeQuery DataSource method, how can I add a Table relation by code x++?
My code:
I don't need to add the table My_Other_Table in forms DataSources, I would like to add the relation by code
public void executeQuery()
{
qbds_1 = this.query().dataSourceTable(tablenum(MyDataSourceTable));
qbds_2 =
this.query().dataSourceTable(tablenum(MyDataSourceTable)).addDataSource(tablenum(My_Other_Table));
qbds_2.addLink(fieldnum(My_Other_Table,RecId), fieldnum(MyDataSourceTable, RecId));
qbds_2.relations(true);
qbds_2.joinMode(JoinMode::InnerJoin);
}
It doesn't work.
Please, could you give me the righ
You want
.relations(false).Truetells the query to use the actual table relation in the AOT. In your case, it is telling the query to look for a relation on yourMy_OtherTablethat refers toMyDataSourceTable, which in the AOT would be\Data Dictionary\Tables\My_Other_Table\Relations\[Some Relation that is table MyDataSourceTable].