Table relation(vendor & factory) filter example

As the screen cut show. factory and vendor is both config in vendor table, which has some "yesorno" field to identify it is vendor or factory or mill.
so in this table. we can specify it in the relationship so that we can only find the vendor or only find the factory in the lookup list.

This is the best practics to do this, instead of using lookup method on a field.

image.png

this achieve the same function as the blow script.

\\ look up vendor
public void lookup()
{
    Query query = new Query();
    QueryBuildDataSource qbds1;
    QueryBuildDataSource qbds2;

    SysMultiTableLookup sysTableLookUp;

    qbds1 = query.addDataSource(tableNum(VendTable));

    qbds1.addRange(fieldNum(VendTable,isFactory)).value(SysQuery::value(NoYes::No));
    qbds1.addRange(fieldNum(VendTable,isMill)).value(SysQuery::value(NoYes::No));

    qbds2 = qbds1.addDataSource(tableNum(DirPartyTable));
    qbds2.joinMode(JoinMode::InnerJoin);
    qbds2.addLink(fieldNum(VendTable,Party),fieldNum(DirPartyTable,RecId));


    sysTableLookup  = SysMultiTableLookup::newParameters(this, query);

    sysTableLookUp.addLookupfield(fieldNum(VendTable,AccountNum),true);
    sysTableLookUp.addLookupfield(fieldNum(DirPartyTable,Name),2);


    sysTableLookUp.performFormLookup();
}

\\lookup factory
public void lookup()
{
    Query query = new Query();
    QueryBuildDataSource qbds1;
    QueryBuildDataSource qbds2;

    SysMultiTableLookup sysTableLookUp;

    qbds1 = query.addDataSource(tableNum(VendTable));

    if(TEX_DevelopDocType::find(TEX_DevelopTable.DevelopDocTypeId).DevelopDocTypeId == enum2str(TEX_ProdType::P01) )
    {
        qbds1.addRange(fieldNum(VendTable,isFactory)).value(SysQuery::value(NoYes::Yes));
    }
    else
    {
        qbds1.addRange(fieldNum(VendTable,isMill)).value(SysQuery::value(NoYes::Yes));
    }

    qbds2 = qbds1.addDataSource(tableNum(DirPartyTable));
    qbds2.joinMode(JoinMode::InnerJoin);
    qbds2.addLink(fieldNum(VendTable,Party),fieldNum(DirPartyTable,RecId));


    sysTableLookup  = SysMultiTableLookup::newParameters(this, query);

    sysTableLookUp.addLookupfield(fieldNum(VendTable,AccountNum),true);
    sysTableLookUp.addLookupfield(fieldNum(DirPartyTable,Name),2);


    sysTableLookUp.performFormLookup();
}

你可能感兴趣的:(Table relation(vendor & factory) filter example)