Wednesday, April 6, 2011

Display all/specific AOT tables in a lookup

For displaying all/specific AOT objects like tables in the lookup control, we need to iterate the UtilidElements table with our desired criteria.

static void lookupAOTTables(FormStringControl _ctrl)
{
    SysTableLookup              sysTableLookup = 
    SysTableLookup::newParameters(tablenum(UtilidElements), _ctrl);
    Query                       query = new Query();
    QueryBuildDataSource        queryBuildDataSource;
    QueryBuildRange             nameQBR, typeQBR;
    ;
    sysTableLookup.addLookupfield(fieldnum(UtilidElements, Name));
    sysTableLookup.addLookupfield(fieldnum(UtilidElements, Id));

    queryBuildDataSource = query.addDataSource(tablenum  
    (UtilidElements));

    nameQBR = queryBuildDataSource.addRange(fieldnum(UtilidElements,
    name));
    nameQBR.value('Cust*');

    typeQBR = queryBuildDataSource.addRange(fieldnum(UtilidElements, recordType));
    typeQBR.value(SysQuery::value(UtilElementType::Table));

    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}

No comments: