Posts Tagged ‘ SysDictField

How to get table field properties from X++


Sometimes while development process you need to get table field properties. One of my customer i need to setup a structure which i have to get all the LedgerJournalTrans table fields names and properties .

In this example i loop all the fields except some system fields and  show names and some properties.

//Dmr Fatih Demirci
static void Dmr_FD_GetTableField(Args _args)
    SysDictTable    dictTable = new SysDictTable(tableNum(LedgerJournalTrans));
    SysDictField    dictField;
    TreeNode        treeNode;
    FieldId         fieldId   = dictTable.fieldNext(0);

    while (fieldId)
        dictField = dictTable.fieldObject(fieldId);

        //Except Sql, System, visible fields
        if (   dictField.isSql()      && !dictField.isSystem()
            && dictField.allowEdit()  && dictField.allowEditOnCreate()
            && dictField.visible()    && !dictField.getCountryRegionCodes( ) )
            treeNode = dictField.treeNode();

                                        dictField.baseType()  ));

        fieldId = dictTable.fieldNext(fieldId);


Happy Daxing.