Get Primary key field name of table in MSD axapta by code

To Get Primary key field name of table in axapta by code you can try following code.

First you need to declare variable for dictTable .

 DictTable _dictTable;  
 DictField _dictField;  
 ;  
 _dictTable = new SysDictTable(tableNum(SalesTable));  
 // Then you need to call primary key field by passing table id like here we have pass salestable and dicttable.id() method will get id of salestable.  
 _dictField = new SysDictField(dictTable.id(), dictTable.primaryKeyField());  
 info(dictField.name());