General X++ Development

How do I dynamically access a field on a table buffer in X++?

Asked by Sunny Vasty· Aug 13, 2026· 1 answers

How do I dynamically access a field on a table buffer in X++?

SSunny Vasty75 reputation · answered Aug 13, 2026

Use a Common buffer and access the field by FieldId.

X++
Common common = custTable;

anytype value = common.(fieldNum(CustTable, AccountNum));

This is useful for generic code.

If you already know the table and field at compile time, normal strongly typed access is still cleaner:

X++
value = custTable.AccountNum;