web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to rename elements of an object

(0) ShareShare
ReportReport
Posted on by 995

Dear All,

I have a requirement where I need to change the naming conventions of objects and elements of objects.

El1.PNG

static void EDRenaming(Args _args)
{
    UtilIdElements utilId;
    str s;
    TreeNode TreeNode;
    TreeNode node;
    str oldName;
    str newName;
    #Properties
    #AOT
    ;
    while select utilId where utilid.recordType == UtilElementType::Enum
    && utilId.name like 'XXX*'
    {
       s = utilId.name;

       node = TreeNode::findNode(#BaseEnumsPath + "\\" + s);
       oldName = node.AOTgetProperty("Name");
       newName = strdel(oldName,1,3);
       node.AOTsetProperty(#PropertyName, "YYY"+newName);
       node.AOTsave();
       node.treeNodeRelease();
       node = null;
    }
}

Here I got the logic to change the name of enum from XXXEnum to YYYEnum, but I didnt get the logic to change the element name i.e., XXXElement1 to YYYElement1..

Can anyone please help me out...

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Sohaib Cheema Profile Picture
    48,811 User Group Leader on at
    RE: How to rename elements of an object

    you must read about SysDictEnum

    SysDictEnum dictEnum = new SysDictEnum( enumnum(YYYEnum) ); 
        int valueIndex;
        
        TreeNode TreeNode;
        TreeNode node;
        
        str oldName;
        str newName;
        #Properties
        #AOT
        
        
        for (valueIndex = 0 ; valueIndex < dictEnum.values(); valueIndex++)
        {
            //labelId = dictEnum.index2LabelId(valueIndex);
            //info(SysLabel::labelId2String2(labelId, languageId));
            node = TreeNode::findNode(dictEnum.path() + '\\' + dictEnum.index2Symbol(valueIndex));   
            oldName = node.AOTgetProperty("Name");
            info(oldName);
            newName = strdel(oldName,1,3);
            node.AOTsetProperty(#PropertyName, "YYY"+newName);
            node.AOTsave();
            node.treeNodeRelease();
            node = null;
        }


  • Suggested answer
    Sohaib Cheema Profile Picture
    48,811 User Group Leader on at
    RE: How to rename elements of an object

    Also don't forget to save parent ENUM after saving kids(elements of enum)

    //write below lines of code as well after what I provided above

    nodeParent = TreeNode::findNode(dictEnum.path());

           nodeParent.AOTsave();

           nodeParent.treeNodeRelease();

           nodeParent = null;

  • AX Techie Profile Picture
    995 on at
    RE: How to rename elements of an object

    Hi Sohaib,

    In similar way how can I change the naming convention if I need to change the name which are in table or form methods...

  • Sohaib Cheema Profile Picture
    48,811 User Group Leader on at
    RE: How to rename elements of an object

    kindly create a new thread/question and explain your requirement there.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

#2
NNaumenko Profile Picture

NNaumenko 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans