SysTableLookup的查找方法错误?

时间:2013-07-24 20:00:19

标签: axapta x++ dynamics-ax-2009

这是应该与添加到Tables \ ProdBOM的任何基本系统一起使用的代码。不知何故,查询正在从字段中删除数据。

static void lookupItemIdBOMSubset(FormStringControl   _ctrl,
                                  ProdId              _prodId)
{
    SysTableLookup          sysTableLookup  = SysTableLookup::newParameters(tableNum(ProdBOM), _ctrl);
    Query                   query           = new Query();
    QueryBuildDataSource    qbds            = query.addDataSource(tableNum(ProdBOM));
    ;

    qbds.addRange(fieldNum(ProdBOM, ProdId)).value(queryvalue(_prodId));
    qbds.addSortField(fieldNum(ProdBOM, LineNum), SortOrder::Ascending);

    sysTableLookup.parmQuery(query);

    sysTableLookup.addLookupfield(fieldNum(ProdBOM, LineNum));
    sysTableLookup.addLookupfield(fieldNum(ProdBOM, BOMId));
    sysTableLookup.addLookupfield(fieldNum(ProdBOM, ItemId), true);

    // This doesn't work \/
    sysTableLookup.addLookupMethod(tablemethodstr(ProdBOM, configId));
    // This doesn't work /\

    sysTableLookup.addLookupMethod(tablemethodstr(ProdBOM, itemName));
    sysTableLookup.addLookupfield(fieldNum(ProdBOM, ProdLineType));
    sysTableLookup.addLookupfield(fieldNum(ProdBOM, InventTransId));

    sysTableLookup.performFormLookup();
}

在Tables \ ProdBOM \ Methods \ configId中,你可以清楚地看到这个代码出了问题。发生什么事了?

//BP Deviation documented
display ConfigId configId()
{
    ProdBOM pb;
    ;
    select firstonly pb where pb.RecId == this.RecId;

    info(strfmt("Bad: [%1, %2], Good:[%3, %4]", this.ItemId, this.InventDimId, pb.ItemId, pb.InventDimId));
    return this.inventDim().ConfigId;
}

2 个答案:

答案 0 :(得分:4)

所以我明白了。在Classes\SysTableLookup\buildSelectionList中,它将查找字段中包含的所有字段添加到QBDS.addSelectionField,它似乎将其从返回字段中删除?

虽然它没有删除RecId,所以我能够创建另一个使用recId重新选择记录的显示方法。

//BP Deviation documented
display ConfigId configIdFromRecId()
{
    return InventDim::find((select firstonly prodBOM where prodBOM.RecId == this.RecId).InventDimId).configId;
}

答案 1 :(得分:1)

您可以通过修改其字段列表强制QueryBuildDatasource加载所需的字段。您可以使用QueryBuildDatasource.fields().addField()方法添加可以获取的字段并由LookupMethod使用