Joining more than 2 datasources to one datasource in x++ query

Hi all,

I was trying to add 3 datasources to a single data source in which they are already having a relation.But when i am adding them in the x++ query, and using the following statement to verify the relation i am not getting the result.

qbds1 = query.adddatasource(Tablenum(table1));

qbds2 = qbds1.adddatasource(tablenum(table2));

qbds3 = qbds 1.adddatasource(tablenum(table3));

qbds4 = qbds1.adddatasource(Tablenum(table4));

info(OPFQuery.dataSourceNo(1).toString());

in the output i am not getting the relations accordingly that are already present with the parent table table1. How to solve this.Thanks in advance.

You didn’t specify any relations. If you want to use the default relations, call relations(true) for on each of the child datasources.

Even though i used the .relations(true) for each child datasource,i was not getting the relations.But when even i tried using

info(datasourceno(dsnumber).tostring()) for each datasource,for each datasource the relation is getting displayed but for parent datasource when i am using the same

info(Datasourceno(1).tostring()),i was not getting all the relations linked to it.Help me out…Thanks in advance

I’m really not sure what you’re describing. Do you say that the query works and you just don’t get what you expect from QueryBuildDataSource.toString()? If it’s the case, you you may have to use fetchMode(QueryFetchMode::One2One) on the child data sources.

If it’s not the case, please give as a concrete example of the problem.