Tuesday, August 28, 2007

Get field label in X++

Scenario: I want to use the label of a field in code.

Answer: Use SysDictField class

SysDictField dict = new SysDictField(tableId, fieldId);
str label = dict.label();


  1. static void Job40(Args _args)
    str label;

    //Get label of field
    label = fieldPName(EmplTable, EmplId);
    info('Field name: '+label);

    //Get label of EDT:
    label = new SysDictType(extendedTypeNum(EmplId)).label();
    info('EDT name: '+label);

    //Get label of table
    label = tablePName(EmplTable);
    info('Table name: '+label);