Hello,
I am trying to join 2 data sources on a form my modifying the query in the executeQuery() of the joined datasource, but after executing the addLink method, I am recieving an error , "Invalid Field/Related field combination".
I am trying to join WMSBillOFLadingOrder onto CustPackingSlipJourusing with SalesId as the relation.
Here is the code:
public void executeQuery()
{
QueryBuildDataSource cpj;
QueryBuildDataSource bol;
query query;
query = CustPackingSlipJour_ds.query();
cpj = query.dataSourceTable(tableNum(CustPackingSlipJour));
bol = cpj.addDataSource(tableNum(WMSBillOfLadingOrder));
bol.joinMoIde(JoinMode::ExistsJoin);
bol.fetchMode(QueryFetchMode::One2One);
bol.relations(false);
bol.addLink(fieldNum(CustPackingSlipJour, SalesId), fieldNum(WMSBillOfLading, InventTransRefId));
super();
}
I tried the same in a job and it worked:
static void Job21(Args _args)
{
Query query;
QueryRun queryrun;
QueryBuildDataSource cpj;
QueryBuildDataSource bol;
QueryBuildRange qbr1;
CustPackingSlipJour custPackingslipJour;
WMSBillOfLadingOrder wmsBillOfLadingOrder;
;
query = new query();
cpj = query.addDataSource(tablenum(CustPackingSlipJour));
qbr1 = cpj.addRange(fieldnum(CustPackingSlipJour,orderAccount));
qbr1.value(queryvalue('CUST001'));
bol = cpj.addDataSource(tablenum(WMSBillOfLadingOrder));
bol.relations(false);
bol.joinMode(joinmode::InnerJoin);
bol.addLink(fieldnum(CustPackingSlipJour,SalesId),fieldnum(WMSBillOfLadingOrder,InventTransRefId));
queryrun = new queryrun(query);
while(queryrun.next())
{
custPackingslipJour = queryrun.get(tablenum(CustPackingSlipJour));
wmsBillOfLadingOrder = queryrun.get(tablenum(WMSBillOfLadingOrder));
info(strfmt("%1 - %2",custPackingslipJour.salesid, wmsBillOfLadingOrder.billOfLadingId));
}
}
I'm not sure if I'm missing something. Does anyone have any insight?
Any help would be appreciated.
Thanks,
Charu