How to add LINK relations in executeQuery DataSource Form?

2k Views Asked by At

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

1

There are 1 best solutions below

0
Alex Kwitny On

You want .relations(false).

True tells 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 your My_OtherTable that refers to MyDataSourceTable, which in the AOT would be \Data Dictionary\Tables\My_Other_Table\Relations\[Some Relation that is table MyDataSourceTable].