Change table properties using X++ code

If you have ever wondered if you can change table’s properties using X++, here is the answer:
static void ChangeTableProperties(Args _args)
{
    xInfo xInfo = new xInfo();
    treeNode node = xInfo.rootNode().AOTfindChild("Data Dictionary");
    treeNode childNode;
    treenodeIterator nodeIterator;
    str properties;
    str tables;
    str newLable = "Change label";
    ;

    node = node.AOTfindChild("Tables");
    nodeIterator = node.AOTiterator();
    childNode = nodeIterator.next();
    while (childNode)
    {
      tables = childNode.treeNodeName();
      if(tables == "AssetBook")
      {
        properties = setProperty(childNode.AOTgetProperties(), "Label", newLable);
        info(properties);
        childNode.AOTsetProperties(properties);
        childNode.AOTsave();
        childNode.AOTrefresh();
      }
      childNode = nodeIterator.next();
    }
}
Although it is not recommended to modify table properties using X++, it will be useful in some specific situation.

Advertisements
This entry was posted in Axapta Development. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s