BLVCKFX
1/28/2020 - 1:54 PM

Multiple Tables in field Lookup method

Here is an example of lookup where you can use multiple tables in the lookup method.

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();
}