Discussion:
How to get the fields names of a table using X++.
(too old to reply)
Manuel E
2011-10-12 23:56:16 UTC
Permalink
Hi,

Does someone know how can I get the fields names of a table using X++.

For example for CustTable I should get:
"AccountNum"
"Name"
"Address"
"Phone"
etc.......



Thanks in advance,
Maroweh
2011-10-13 13:06:57 UTC
Permalink
Post by Manuel E
Hi,
Does someone know how can I get the fields names of a table using X++.
"AccountNum"
"Name"
"Address"
"Phone"
etc.......
Thanks in advance,
Hi,

You can use the DictTable and DictField classes for this.

Maroweh
Rudi Hansen
2011-10-23 11:05:51 UTC
Permalink
Post by Manuel E
Does someone know how can I get the fields names of a table using X++.
This should do the trick, i got the idea from Global.buf2Con

static void FieldNamesFromTable(Args _args)
{
CustTable CustTable;
common table = CustTable;
DictTable dictTable = new DictTable(table.tableId);
fieldId fieldId = dictTable.fieldNext(0);

while (fieldId)
{
print fieldId2Name(table.TableId,fieldId);
fieldId = dictTable.fieldNext(fieldId);
}
pause;
}

Loading...