Jan 5, 2012

form control in a lookup

Fetching the customers from CustTable those are having the sales orders in sales table in a form control in a lookup

for that, just override the lookup method of the form control and write this code.
public void lookup()
{
       //super();
       SalesTable   SalesTable;

        // Declaration
        Query   LookupQuery    = new Query();
        QueryBuildDataSource     LookupQueryBuildDataSource;
        QueryBuildRange             LookupQueryBuildRange;
        SysTableLookup CustomSysTableLookup = SysTableLookup::newParameters(tableNum(SalesTable), this);
        ;
        // Add fields that you want in Lookups
        CustomSysTableLookup.addLookupField(fieldNum(CustTable, Name));
        CustomSysTableLookup.addLookupField(fieldNum(SalesTable, CustAccount));
        // Add DataSource
        LookupQueryBuildDataSource   = LookupQuery.addDataSource(tableNum(SalesTable));

        // Execute the Query
        CustomSysTableLookup.parmQuery(LookupQuery);
        CustomSysTableLookup.performFormLookup();
}

No comments: