很多情况下,我们会需要通过TableId和RecId来直接获得数据表记录。比如在Dynamics AX中实现全文检索的时候,一种合理的设计就是让全文检索返回RecId,然后再根据不同的TableId构建数据表实例,最终根据返回的RecId获得数据表记录,从而将结果显示给用户。
相关代码如下:
static void Job2(Args _args) { RecId recId = 5637144576; TableId tableId = 77; // CustTable Common common; SysDictTable dictTable; CustTable custTable; ; dictTable = new SysDictTable(tableId); common = dictTable.makeRecord(); select firstonly common where common.RecId == recId; // Here we got a CustTable record // whose RecId is 5637144576 custTable = common; // Assign to CustTable info(custTable.Address); }