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

Joining datasources by name in AX 2012 form

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

有 InventTable(InventTableComplaints) - 父项和 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();
}

但是没用。 可能吗?

您没有在 executeQuery 方法中定义 table 关系,而是在只执行一次的 init 方法中定义。如果您在表单中定义了数据源(使用 InventTableComplaint 作为 JoinSource 并使用 OuterJoin 作为 JoinMode),则不需要在 init 方法中执行此操作要么,但如果未提供 table 关系,您可能需要定义 link:

public void init()
{
    qbdsIT = InventTableComplaint_DS.queryBuildDataSource();
    qbdsERPTC = EcoResProductTranslationComplaint_ds.queryBuildDataSource(); 
    qbdsERPTC.clearLinks();
    qbdsERPTC.addLink(fieldNum(InventTable, Product), fieldNum(EcoResProductTranslation, Product));
    super();
}

请注意,每个 InventTable 可能存在多个 EcoResProductTranslation 的记录(对每种语言而言),因此您可能会以 "duplicates" 的 InventTable 结束] 在网格中。