23 Temmuz 2013 Salı

AXAPTA - Lookup and sort

When creating lookup you will see lookup won't run with your selected sort field:

public void lookup()
{
    SysTableLookUp          sysTableLookUp = SysTableLookup::newParameters(tablenum(SMARepairStage),RepairStageId);
    Query                   query = new Query();
    QueryBuildDataSource    qbds = query.addDataSource(tablenum(SMARepairStage));
        qbds.addSortField(fieldnum(SMARepairStage,Name));
        qbds.orderMode(OrderMode::OrderBy);
    sysTableLookup.addLookupfield(fieldnum(SMARepairStage,RepairStageId));
    sysTableLookup.addLookupfield(fieldnum(SMARepairStage,Name));
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}


If you may do this change, you will see your lookup how  do you want to do:

public void lookup()
{
    SysTableLookUp          sysTableLookUp = SysTableLookup::newParameters(tablenum(SMARepairStage),RepairStageId);
    Query                   query = new Query();
    QueryBuildDataSource    qbds = query.addDataSource(tablenum(SMARepairStage));
        qbds.addSortField(fieldnum(SMARepairStage,Name));
        qbds.orderMode(OrderMode::OrderBy);
    sysTableLookup.addLookupfield(fieldnum(SMARepairStage,RepairStageId));
    sysTableLookup.addLookupfield(fieldnum(SMARepairStage,Name));
    sysTableLookup.parmQuery(query);
    sysTableLookup.parmUseLookupValue(false);
    sysTableLookup.performFormLookup();
}

Hiç yorum yok:

Yorum Gönder