Interview Questions

Friday, July 4, 2014

Multiple Tables in field Lookup method

How To use Multiple Tables in Form LookUp

public void lookup()
{
  Query                   query = new Query();
  QueryBuildDataSource    qbdsPurchTable,QbdsInvntQO, qbdsInventDim;
  QueryBuildRange         qbrVendId,qbrPurchStatus,qbrPurchType;
  QueryBuildLink          qblink1, QbLink2;

  SysTableLookup  sysTableLookup = sysTableLookup::newParameters(tableNum(PurchTable), this);
  ;//breakpoint;
  qbdsPurchTable = query.addDataSource(tableNum(PurchTable));

  QbdsInvntQO = qbdsPurchTable.addDataSource(tableNum(InventQuarantineOrder));
  QbdsInvntQO.relations(false);
  QbdsInvntQO.joinMode(JoinMode::NoExistsJoin);
  qblink1 =  QbdsInvntQO.addLink(FieldNum(PurchTable,PurchId),FieldNum(InventQuarantineOrder,TransRefId));

  qbdsInventDim = QbdsInvntQO.addDataSource(tableNum(InventDim));
  qbdsInventDim.relations(false);
  qbdsInventDim.joinMode(JoinMode::NoExistsJoin);
  QbLink2 = qbdsInventDim.addLink(FieldNum(InventQuarantineOrder,InventDimId),FieldNum(InventDim,InventDimId));

  qbdsPurchTable.addRange(fieldNum(PurchTable, OrderAccount)).value(PurchTable_InvoiceAccountGrid.valueStr());
  qbdsPurchTable.addRange(FieldNum(PurchTable, PurchStatus)).value("Invoiced,Received");
  QbdsInvntQO.addRange(fieldNum(InventQuarantineOrder, Status)).value(queryValue(InventQuarantineStatus::Ended));
  qbdsInventDim.addRange(fieldNum(InventDim, InventLocationId)).value("102018");

  sysTableLookup.addLookupfield(fieldNum(PurchTable,OrderAccount));
  sysTableLookup.addLookupfield(fieldNum(PurchTable,PurchId),true);
  sysTableLookup.addLookupfield(fieldNum(PurchTable,PurchStatus));

  sysTableLookup.parmQuery(query);
  sysTableLookup.performFormLookup();
}

No comments:

Post a Comment