Aug 18, 2016

Field properties update by using X++ (소스코드로 필드 속성 업데이트)

static void update_FieldLabelProperties(TableName    _TableName,
                                        FieldName    _FieldName,
                                        LabelId      _LabelId)
{
    str                 _TableNodePath;
    str                 _FieldNodePath;
    TreeNode            _TableRoot;
    TreeNode            _FieldRoot;
    TreeNodeIterator    _Fieldterator;
    TreeNode            _Fields;
    str property;
   
    _TableNodePath = strFmt("\\Data Dictionary\\Tables\\%1",_TableName);
    _FieldNodePath = strFmt("\\Data Dictionary\\Tables\\%1\\Fields",_TableName);
   
    _TableRoot = treeNode::findNode(_TableNodePath);
    _FieldRoot = treeNode::findNode(_FieldNodePath);
    _Fieldterator = _FieldRoot.AOTiterator();
    _Fields = _Fieldterator.next();
   
    while(_Fields)
    {
        if(_Fields.AOTgetProperty("Name") == _FieldName)
        {
            property = setProperty(_Fields.AOTgetProperties(),"Label",_LabelId);
            //info(property);
            _Fields.AOTsetProperties(property);
            _Fields.AOTsave();
            _Fields.AOTrefresh();
        }
       
        _Fields = _Fieldterator.next();
    }
   
    _TableRoot.AOTsave();
    _TableRoot.AOTrefresh();
}

No comments:

Post a Comment