Browsing the Data dictionary through X++ code is easier than you may think. Let’s say you want to list all of the fields in table InventTable.
This is one way to do it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | static void FO_dataDictionary(Args _args) { Dictionary dictionary = new Dictionary(); DictTable table; DictField field; InventTable inventTable; int j; ; table = dictionary.tableObject(inventTable.TableId); print table.id(); print table.name(); pause; for(j=1; j <= table.fieldCnt(); j++) { field = new DictField(table.id(), table.fieldCnt2Id(j)); print field.name(); } pause; } |
Using this job we list all of the fields in InventTable, even the system fields such as dataAreaId and createdDate. If we want to exclude the system fields we add an If – statement that checks if the fields are system fields using the method isSystem():
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | static void FO_dataDictionary(Args _args) { Dictionary dictionary = new Dictionary(); DictTable table; DictField field; InventTable inventTable; int j; ; table = dictionary.tableObject(inventTable.TableId); print table.id(); print table.name(); pause; for(j=1; j <= table.fieldCnt(); j++) { field = new DictField(table.id(), table.fieldCnt2Id(j)); if(!field.isSystem()) { print field.name(); } } pause; } |
Last 5 posts in Development
- No valid document identified from the entity key - April 9th, 2010
- Using Regular Expressions in Dynamics AX - October 2nd, 2009
- Create class and methods in x++ - December 22nd, 2008
- Simple field lookup in form - October 13th, 2008
- Get your Intercompany CustAccount - September 29th, 2008