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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to add enum values to AOT by through code by xml editing.

(0) ShareShare
ReportReport
Posted on by 157

Hi every one,

I am doing some R&D on xml editing.

I had one test enum and it has two enum values pen and pencil. I want to add  a new element i.e node let us say scale.

class CreatingEnumThroughXml

{

   // public static void main(Args _args)

   // container strpath;

 

 

   public static void main(Args _args)

   {

       str path;

       

       //nodeXml = xDoc.createElement("scale")

       XmlElement xmlName ,xmlAXEnumValue,XmlValue;

       XmlNode  enumValues , AXEnumValue,AxValue;

       FileIoPermission permission;

        permission  =    new

            FileIoPermission("K:\AosService\PackagesLocalDirectory\HandelAndKontor\HandelAndKontor\AxEnum\TestEnum1.xml",'w');

     

       XmlText xmlNameText,xmlValueText;

 

      

        path = @"K:\AosService\PackagesLocalDirectory\mymodel\mymodel\AxEnum\TestEnum1.xml";

        XmlDocument xDoc = new XmlDocument();

        xDoc.Load(path);

        xmlName         =   xDoc.createElement("Name");

        XmlValue        =   xDoc.createElement("Value");

        xmlAXEnumValue  =   xDoc.createElement("AXEnumValue");

        AXEnumValue     =   xDoc.documentElement().selectSingleNode("EnumValues").appendChild(xmlAXEnumValue);

       // enumValues  = xDoc.documentElement().selectSingleNode("EnumValues").appendChild(xmlName);

        enumValues      =   AXEnumValue.appendChild(xmlName);

        AxValue         =   AXEnumValue.appendChild(XmlValue);

 

        xmlNameText = xDoc.createTextNode("Scale");

        xmlValueText= xDoc.createTextNode("2");

        enumValues.appendChild(xmlNameText);

        AxValue.appendChild(xmlValueText);

 

        xDoc.save(path);

     

       

}

 

}

For this new node is getting added to xml but it is not reflecting in the AOT.

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    You can't manipulate AOT elements in runtime in D365FO.

    What is your business requirement? If you need a dynamic list, don't use fixed list (enum). Instead store the list values in separate table. In standard system such examples are for example customer groups and payment terms.

  • Neetha Profile Picture
    157 on at

    Hi Nikolaos,

    We have created some AOT elements in the run time by creating an xml file. There is no business requirement I just want to explore can we change the AOT elements by editing the xml file or not.

  • Martin Dráb Profile Picture
    239,040 Most Valuable Professional on at

    But what's point? You can't use this code outside development environments (runtime runs binaries, not source code) and in development environments, you have development tools for working with source code. If you want a code generator, write a Visual Studio extension instead of putting it into the business logic of your ERP system.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 616

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 460 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 331 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans