2017-08-09 35 views
0

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

有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(); 
} 

但它不工作。 这可能吗?

+0

看起来你正在做'addDataSource'来添加另一个数据源,当它已经存在于表单上时。 –

回答

1

您没有在executeQuery方法中定义表格关系,而是在init方法中这样做,而只执行一次。如果您在表单中定义的数据源(使用InventTableComplaintJoinSourceOuterJoinJoinMode),你不需要做这件事init方法要么,但你可能需要定义链接,如果没有表关系提供:

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

要注意的是一个以上的记录可以为每个InventTable存在的EcoResProductTranslation(对每种语言),所以你可以在网格的InventTable“重复”结束了。

+0

最后,我最终解决了基于将转换插入到父数据源(上面的'InventTable')并且没有加入表单中的任何内容的解决方案。但是你的解决方案让我更好地理解关系从何而来。广告。不同的语言:你是对的,我也必须添加'QueryBuildRange'到'qbdsERPTC' – dreptak