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

Notifications

Announcements

No record found.

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,160 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
    237,801 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

Responsible AI policies

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

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans