最新消息:ww12345678 的部落格重装上线,希望大家继续支持。

AX 2012: Setting Labels in X++

网络文摘 William 1219浏览 0评论

To set Label property of all the fields of a table in AOT, you may refer to the following code which loops through all the fields of a table and sets their Label property with their Name property.

static void MAKSetLabels(Args _args)
{
    #Properties
    SysDictTable    dictTable = new SysDictTable(tableNum(CustTable));
    SysDictField    dictField;
    TreeNode        treeNode;
    FieldId         fieldId = dictTable.fieldNext(0);
    str             fieldName;
    

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

        if (dictField.isSql() && !dictField.isSystem())
        {
            treeNode = dictField.treeNode();
            
            fieldName = treeNode.AOTgetProperty(#PropertyName);
            treeNode.AOTsetProperty(#PropertyLabel, fieldName);
            treeNode.AOTsave();
            
            info(strFmt("Field name: %1 | Field label: %2",
                treeNode.AOTgetProperty(#PropertyName),         //Field name
                treeNode.AOTgetProperty(#PropertyLabel)));      //Field label
            
            treeNode.treeNodeRelease();
            treeNode = null;
        }

        fieldId = dictTable.fieldNext(fieldId);
    }
}

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址