Tuesday, June 8, 2010

Creating Lookups

here is a sample code to create lookups on a form field

public void lookup()
{
    SysTableLookup        sysTableLookup = SysTableLookup::newParameters(tableNum(YourAXTable, this);
    Query                 query = new query();
    QueryBuildDataSource  queryBuildDataSource = query.addDataSource(tableNum(YourAXTable));
    QueryBuildRange       range1 = queryBuildDataSource.addRange(fieldNum(YourAXTable, FieldYouWantFiltered1));
    QueryBuildRange       range2 = queryBuildDataSource.addRange(fieldNum(YourAXTable, FieldYouWantFiltered2));
    ;

    range1.value(queryValue(YourFormField.valuestr()));
    range2.value(queryValue(YourFormField2.valuestr()));

    sysTableLookup.addLookupfield(fieldNum(YourAXTable, FieldYouWantReturned));
    sysTableLookup.addLookupfield(fieldNum(YourAXTable, AdditionalLookupColumn));

    sysTableLookup.parmQuery(query);

    sysTableLookup.performFormLookup();

}

No comments:

Post a Comment