Create and read XML using XSD tool in AX 2012Continue reading
In Dynamics AX there is no standard feature to serialise/ de-serialise data to XML file based on an XSD schema.
Each time when we want to do this we must create new code and create/read node by node the XML file. So, to make this in dynamic way we can use the Microsoft XSD tool in visual studio to generate serialisation/deserialisation classes and then deploy and use them in Microsoft Dynamics AX.
I will not go in details about creating the serialisation/deserialisation classes because this part is very well explained in many articles about using XSD tool. I will take the example from Yogesh Joshi's Blog and work on top of it to integrate it in Microsoft Dynamics AX 2012. The following prerequisites are needed before starting:
- Create the Students.xsd XML schema file.
- Generate the Students.cs class and deploy the solution to Microsoft Dynamics AX 2012.
Note: In order to deploy the classes to AOT you need to have installed Visual Studio tools for Microsoft Dynamics AX on VS 2010.
Note: Before deployment to AOT make sure that the class is contained in namespace:
By analysing the generated serialisation/deserialisation class we can see that for each XML node one partial class has been created. For repeating nodes two classes are created, one is array of the same class and the other is the standard class with all the get and set methods for node values. We need to declare variables for all these classes in Dynamics AX. I have created a simple for loop with final length of 7 that will insert seven records into XML file:
static void xmlSerialize(Args _args)
System.Xml.XmlWriter xmlWriter = Sys-tem.Xml.XmlWriter::Create(@'C:\Test\StudentsCreated.xml');
XmlSerializationClassLibrary.Students serializedStudents = new XmlSerialization-ClassLibrary.Students();
System.Xml.Serialization.XmlSerializer serializer = new Sys-tem.Xml.Serialization.XmlSerializer(serializedStudents.GetType());
System.String testName, testAddress;
int length = 7;
permission = new InteropPermission(InteropKind::DllInterop);
if (permission == null)
//initialize the array object that will store multiple objects of type StudentsStudent
stud = new XmlSerializationClassLibrary.StudentsStudent[length]();
for (i = 0; i < length; i++)
//initialize StudentsStudent object
studentInserted = new XmlSerializationClassLibrary.StudentsStudent();
//set students name in the StudentsStudent object
testName = strFmt("Name %1", int2str(i));
//set rollid in the StudentsStudent object
testRollId = System.Convert::ToByte(i);
//set address in the StudentsStudent object
testAddress = strFmt("Address %1", int2str(i));
//set StudentsStudent value for the StudentsStudent array object
//set value for the top level node object Students
//call serializer with passing the xmlWriter that contains the file info and serializedStu-dents which contains all data objects
e = CLRInterop::getLastException();
info( e.get_Message() );
e = e.get_InnerException();
In same way we can generate serialisation/deserialisation classes using XSD tool for other XML schemas or if we do not have the XML schema we could create it either automatically again with XSD tool or manually. After that it is very easy to use those classes in Dynamics AX and generate or read XML files with writing little and understandable code.
Implementing a new ERP system in an organisation is always a challenge. Users question whether they will be able to cope with analysing the data flow in an integrated system without external support. The accountant wonders whether all the set-up accounts are correct. The chief technologist cannot get rid of troublesome thoughts about whether the routings and boms are set up optimally. This is why it is so important to have a reliable service team to help the company control the system in the post-implementation stage. In this article, we take a look at the issues surrounding the implementation of an ERP system and the benefits of maintaining proactive service support.
328.77 million terabytes of data are generated every day - this is the estimate for the first quarter of 2023 (1). These are massive amounts of data on a global scale. On a smaller scale, such as an enterprise, it's difficult to estimate because it depends on the organisation in question, but one thing is certain - collecting, processing and analysing this data is the key to business success today. Why is the Data Lake service so important for data analysis and reporting in Microsoft Dynamics 365 Finance and Operations? How can you tame the data by integrating Microsoft Power BI analytics with Data Lake? We have drawn up some tips.
The retail industry is still dealing with the effects of the pandemic that lasted almost three years. In addition to this, further global events are causing disruption to the supply chain or financial stability of many retailers globally. As the industry confronts new challenges shaped by economic and geopolitical factors, it also faces trends influenced by changing customer expectations and needs. Here are 5 developments and trends to watch.
An interactive, AI-powered support for sales, customer service, marketing, and supply chain - Microsoft Dynamics 365 Copilot leverages generative AI and natural language processing technology to perform simple, yet time-consuming daily tasks that workload employees but can be automated.