Monday, 15 December 2014

Create Lookup method with sorting & range on items for same Sales order items

\Forms\SalesTable\Data Sources\SalesLine\Fields\MTI_RollTo\Methods\lookup
// for creating dropdown list (lookup) of items for same SalesId in SalesLine
public void lookup(FormControl _formControl, str _filterStr)
{
    Query                   query;
    QueryBuildDataSource    queryBuildDataSource;
    Args                    args = new Args();

    SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(SalesLine),_formControl);
    ;

    if (args && args.dataset())
    {
        switch(args.dataset())
        {
            case tableNum(SalesLine) :
            SalesLine = args.record();
            break;
        }
    }
    query = new Query();
    queryBuildDataSource = query.addDataSource(tablenum(SalesLine));

    sysTableLookup.addLookupfield(fieldnum(SalesLine, ItemId),true);
    sysTableLookup.addLookupMethod("itemname");
    sysTableLookup.addLookupfield(fieldnum(SalesLine, hrtManufacturerPartNo));

    queryBuildDataSource.addSortField(fieldnum(SalesLine, ItemId));

    queryBuildDataSource.addRange(fieldnum(SalesLine, SalesId)).value(SalesLine.SalesId);

    sysTableLookup.parmQuery(query);
    sysTableLookup.parmUseLookupValue(true);

    sysTableLookup.performFormLookup();

}

No comments:

Post a Comment