2017-08-09 49 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