In development phase, many case leads developer to iterator overall/some
non-system field of a table to perform some computational on it. Iteration over
field also include some systems fields like RecId, Createddatetime etc.
Before look into complete code. We must have to understand
some terminology/classes before
development.
What are the objects Dict*?
Dict objects are
generally used for creating an object of related type (for DictClass e.g.
CustBalanceList class), getting information about that object (for DictClass
e.g. is class defined Abstract, Final or is Runnable {has main method}) etc.
DictClass
Object can be constructed by
“new” word (Params: ClassId). Mostly and effectively used for creating a
child class (if we know classId of it).
SysDictTable dictTable
= new SysDictTable(currentTable.TableId);
DictField
Object can be constructed by
“new” word (Params: TableId, FieldId). Mostly used for finding basetype
or label etc of any table field.
SysDictField
dictField;
FieldId
FieldId is the unique identifier for field present in a
particular table, used to store field value.
FieldId fieldId =
dictTable.fieldNext(0);
Code - Iterator over non-system
fields of a table in AX
SysDictTable dictTable = new SysDictTable(currentTable.TableId);
SysDictField dictField;
FieldId fieldId = dictTable.fieldNext(0);
while (fieldId)
{
dictField = dictTable.fieldObject(fieldId);
if(dictField.isSql() && !dictField.isSystem())
{
{
//write your code here
info(strFmt("%1: %2", dictField.name(),currentTable.(fieldId)));
}
fieldId = dictTable.fieldNext(fieldId);
}
No comments:
Post a Comment