在AX 2012表单中按名称加入数据源

时间:2017-08-09 14:05:20

标签: forms datasource axapta dynamics-ax-2012

我试图在我创建的网格中加入多个数据源。 网格采用CaseDetail形式,它使用与其他组相同的表。 因此,我必须使用基于数据源名称的连接而不是表名。

有InventTable(InventTableComplaints) - parent和EcoResProductTranslation(EcoResProductTranslationComplaints) - 孩子。

我尝试做的是将此代码添加到子数据源:

public void executeQuery()
{
    QueryBuildDataSource qbdsIT, qbdsERPTC;

    qbdsIT = InventTableComplaint_DS.queryBuildDataSource();
    qbdsERPTC = qbdsIT.addDataSource(tableNum(EcoResProductTranslation), "EcoResProductTranslationComplaint");

    qbdsERPTC.addLink(fieldNum(InventTable, Product), fieldNum(EcoResProductTranslation, Product));

    qbdsERPTC.joinMode( JoinMode::OuterJoin );
    qbdsERPTC.fetchMode( QueryFetchMode::One2One );

    super();
}

但它不起作用。 有可能吗?

1 个答案:

答案 0 :(得分:1)

您没有在Trap方法中定义表关系,而是在executeQuery方法中执行此操作,而不是仅执行一次。如果您在表单中定义了数据源(使用init作为InventTableComplaint并使用JoinSource作为OuterJoin),则无需在JoinMode方法中执行此操作或者,如果没有作为表关系提供,您可能需要定义链接:

init

请注意每个public void init() { qbdsIT = InventTableComplaint_DS.queryBuildDataSource(); qbdsERPTC = EcoResProductTranslationComplaint_ds.queryBuildDataSource(); qbdsERPTC.clearLinks(); qbdsERPTC.addLink(fieldNum(InventTable, Product), fieldNum(EcoResProductTranslation, Product)); super(); } (每种语言都有)的EcoResProductTranslation可能存在多条记录,因此您可能会在网格中以InventTable的“重复”结尾