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.
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.
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.
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.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156