2011-04-04 53 views
0

目前,我正在使用Conversion Studio將CSV文件導入並將內容存儲在AX表中。這部分工作。我有一個塊定義和字段正確映射。使用Conversion Studio通過增加將註釋導入Microsoft Dynamics AX 2009

CSV文件包含多個註釋列,如註釋1,註釋2等。這些註釋列有固定數量。公衆意見標記爲Comments-1 ... 5,私人意見標記爲Private-Comment-1 ... 5。

希望的結果是將數據帶入AX表(正如當前的工作)並且將註釋字段連接起來或將它們作爲單獨的註釋作爲內部或外部註釋存儲到DocuRef表中。

難道不需要在Conversion Studio項目中設置一個新的塊,我已經設置好了嗎?你能否指點我可能會顯示類似程序或如何執行此操作的資源?

在此先感謝!

回答

0

追兔子下來最深的兔子洞後,我發現最簡單的方式來做到這一點,像這樣:

覆蓋你的文件處理器的onEntityCommit方法(即擴展AppDataDocumentHandler),像這樣:

AppEntityAction onEntityCommit(AppDocumentBlock documentBlock, AppBlock fromBlock, AppEntity toEntity) 
{ 

    AppEntityAction ret; 
    int64 recId; // Should point to the record currently being imported into CMCTRS 
    ; 
    ret = super(documentBlock, fromBlock, toEntity); 
    recId = toEntity.getRecord().recId; 
    // Do whatever you need to do with the recId now 
    return ret; 

} 

這裏是我的方法插入註釋,如果你需要它:

private static boolean insertNote(RefTableId _tableId, int64 _docuRefId, str _note, str _name, boolean _isPublic) 
{ 
    DocuRef docuRef; 
    boolean insertResult = false; 
    ; 
    if (_docuRefId) 
    { 
    try 
    { 
     docuRef.clear(); 
     ttsbegin; 
     docuRef.RefCompanyId = curext(); 
     docuRef.RefTableId = _tableId; 
     docuRef.RefRecId = _docuRefId; 
     docuRef.TypeId = 'Note'; 
     docuRef.Name = _name; 
     docuRef.Notes = _note; 
     docuRef.Restriction = (_isPublic) ? DocuRestriction::External : DocuRestriction::Internal; 
     docuRef.insert(); 
     ttscommit; 

     insertResult = true; 
    } 
    catch 
    { 
     ttsabort; 
     error("Could not insert " + ((_isPublic) ? "public" : "private") + " comment:\n\n\t\"" + _note + "\""); 
    } 
    } 
    return insertResult; 
} 
相關問題