Reputation: 303
I'm trying to join multiple datasources in a grid I created. The grid is in CaseDetail form and it uses same tables as some other groups on it. Therefore I have to use joins based on datasources names and not on tables names.
There is InventTable(InventTableComplaints) - parent and EcoResProductTranslation(EcoResProductTranslationComplaints) - child.
What I'm trying to do is to add this code to the child datasource:
public void executeQuery()
{
QueryBuildDataSource qbdsIT, qbdsERPTC;
qbdsIT = InventTableComplaint_DS.queryBuildDataSource();
qbdsERPTC = qbdsIT.addDataSource(tableNum(EcoResProductTranslation), "EcoResProductTranslationComplaint");
qbdsERPTC.addLink(fieldNum(InventTable, Product), fieldNum(EcoResProductTranslation, Product));
qbdsERPTC.joinMode( JoinMode::OuterJoin );
qbdsERPTC.fetchMode( QueryFetchMode::One2One );
super();
}
But it doesn't work. Is it possible?
Upvotes: 0
Views: 3584
Reputation: 18051
You do not define the table relations in the executeQuery
method, do so in the init
method instead which is executed exactly once. If you defined the datasource in the form (using InventTableComplaint
as JoinSource
and with OuterJoin
as JoinMode
), you do not need to do it in init
method either, but you may need to define the link if not provided as table relations:
public void init()
{
qbdsIT = InventTableComplaint_DS.queryBuildDataSource();
qbdsERPTC = EcoResProductTranslationComplaint_ds.queryBuildDataSource();
qbdsERPTC.clearLinks();
qbdsERPTC.addLink(fieldNum(InventTable, Product), fieldNum(EcoResProductTranslation, Product));
super();
}
Beware that more than one record of may exist of EcoResProductTranslation
for each InventTable
(on for each language), so you may end out with "duplicates" of InventTable
in the grid.
Upvotes: 1