By TableId and RecId extract data table records

In many cases, we will need to TableId and RecId to directly access the data table records. For example, in Dynamics AX time to achieve full-text search, a reasonable design is to allow full-text search to return RecId, and then built based on different data tables TableId instance, the final return of RecId based access to data table records, so the results displayed to the user .

The code is as follows:

static void Jimmy_dataFromTableIdAndRecId(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);  
} 

 

posted @ 2010-09-11 13:19  Fandy Xie  Views(329)  Comments(0Edit  收藏  举报