Hi Friends,
The below piece of X++ code can be used to read properties of table fields.
To demonstrate, the below job will check the mandatory property of the fields of a table. This comes handy during technical analysis. It can be time consuming to check the property of each field manually.
The code uses DictTable and DictField classes to iterate through the table fields and it's properties. This can also be used to check other properties of the fields of a table.
static void checkProperties(Args _args)
{
DictTable dictTable;
DictField dictField;
int i, cnt;
dictTable = new DictTable(tableNum(CustTable));
cnt = dictTable.fieldCnt();
for (i= 1; i<=cnt;i++)
{
dictField = new DictField(tableNum(CustTable),dictTable.fieldCnt2Id(i));
if (dictField.mandatory())
{
info (strFmt("Field %1 is mandatory.",dictField.label()));
}
}
}
Similar to the way we have checked the property of field using dictField object in the above job, we can also read properties of any table using the dictTable object.
These classes are used at lot of places in standard AX code to iterate through table structures. Some common scenario are when we need to show list of table/fields in lookups.
The below piece of X++ code can be used to read properties of table fields.
To demonstrate, the below job will check the mandatory property of the fields of a table. This comes handy during technical analysis. It can be time consuming to check the property of each field manually.
The code uses DictTable and DictField classes to iterate through the table fields and it's properties. This can also be used to check other properties of the fields of a table.
static void checkProperties(Args _args)
{
DictTable dictTable;
DictField dictField;
int i, cnt;
dictTable = new DictTable(tableNum(CustTable));
cnt = dictTable.fieldCnt();
for (i= 1; i<=cnt;i++)
{
dictField = new DictField(tableNum(CustTable),dictTable.fieldCnt2Id(i));
if (dictField.mandatory())
{
info (strFmt("Field %1 is mandatory.",dictField.label()));
}
}
}
Similar to the way we have checked the property of field using dictField object in the above job, we can also read properties of any table using the dictTable object.
These classes are used at lot of places in standard AX code to iterate through table structures. Some common scenario are when we need to show list of table/fields in lookups.
Hi Priyanka i have doubt about table properties, can i change the table properties by using X++ code.
ReplyDeleteHi Raghu,
ReplyDeleteYes you can change table properties using X++ code, however this is not recommended. Can you please share any business scenario where you would like to do this. Refer to this blog:
https://fredshen.wordpress.com/2006/02/05/change-table-properties-using-x-code/
Have a great day.
Microsoft Dynamics AX
ReplyDeleteImprove your administrative and operational processes with the invaluable prosecute of Dynamics AX. Let us fabour you resource all significant features of Dynamics AX and watch your business as it grows significantly.
For more info: http://crmwebx.com/