Custom lookup example 2

public void lookup()
{
   // super();

    SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(SalesTable), this);
    Query query = new Query();
    QueryBuildDataSource qbds,qbds2,qbds3;

    qbds = query.addDataSource(tablenum(SalesTable));
    qbds.addOrderByField(fieldNum(SalesTable,SalesId));
    qbds.addOrderByField(fieldNum(SalesTable,SalesName));
    qbds.addOrderByField(fieldNum(SalesTable,SalesType));
    qbds.addOrderByField(fieldNum(SalesTable,CustAccount));

    qbds.addGroupByField(fieldNum(SalesTable,SalesId));
    qbds.addGroupByField(fieldNum(SalesTable,SalesName));
    qbds.addGroupByField(fieldNum(SalesTable,SalesType));
    qbds.addGroupByField(fieldNum(SalesTable,CustAccount));
    
    qbds2 = qbds.addDataSource(tableNum(TECDeliveryOrderTable));
    qbds2.joinMode(JoinMode::NoExistsJoin);
    qbds2.relations(false);
    qbds2.addLink(fieldNum(SalesTable,SalesId),fieldNum(TECDeliveryOrderTable,TIDUnlockSalesId));

    qbds3 = qbds.addDataSource(tableNum(SalesLine));
    qbds3.joinMode(JoinMode::InnerJoin);
    qbds3.relations(false);
    qbds3.addLink(fieldNum(SalesTable,SalesId),fieldNum(SalesLine,SalesId));
    qbds3.addRange(fieldNum(SalesLine,ItemId)).value(InventParameters::find().TIDItemIdServices);


    sysTableLookup.addLookupfield(fieldnum(SalesTable, SalesId),true);
    sysTableLookup.addLookupfield(fieldNum(SalesTable,SalesName));
    sysTableLookup.addLookupfield(fieldNum(SalesTable,SalesType));
    sysTableLookup.addLookupfield(fieldNum(SalesTable,CustAccount));
    sysTableLookup.addLookupMethod("customerName");
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();

}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s