HOW TO load xml from a file in C/AL

In the following example we are going to: open a file, create an InStream object, create an XmlDocument using the DotNet component and load the xml from the InStream.

This example requires that you create the following variables:

Name DataType Subtype
TestFile File
Istream InStream
XmlDoc DotNet
System.Xml.XmlDocument.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

HOW TO load xml from a file in C/AL?

TestFile.OPEN('C:\TestFolder\TestFile.xml');
TestFile.CREATEINSTREAM(Istream);

XmlDoc := XmlDoc.XmlDocument();
XmlDoc.Load(Istream);

Did my HOW TO help you? Leave a reply.

Could not load file or assembly Microsoft.Dynamics.Nav.Management.dll HRESULT: 0x80131515

Information
—————————

Could not load file or assembly ‘file:///C:\Program Files\Microsoft Dynamics NAV\70\Service\Microsoft.Dynamics.Nav.Management.dll’ or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
—————————
OK
—————————

Symptoms:
After an update with a new build of Microsoft Dynamics NAV the Microsoft Dynamics NAV Administration tool does not work showing an error message as above.

Solution:

  1. Move the file Microsoft.Dynamics.Nav.Management.dll from the folder
    C:\Program Files\Microsoft Dynamics NAV\70\Service\

    into your Desktop

  2. Right-click on the file, select Properties and in the General tab push the button at the bottom Unblock
  3. Move the file Microsoft.Dynamics.Nav.Management.dll from the Desktop to the original folder
    C:\Program Files\Microsoft Dynamics NAV\70\Service\

Did my solution solve your problem? Leave a comment.

HOW TO test if a DateFormula variable is empty

We can learn a lot reading Microsoft standard C/AL code.

HOW TO test if a DateFormula variable is empty?

An example is offered in the Table 5088 Profile Questionnaire Line

TESTFIELD("Starting Date Formula",ZeroDateFormula);

Solution:
Create a Global Variable named like ZeroDateFormula of DataType DateFormula and don’t assign any value to it.

Now you can use this variable to test if a DateFormula variable is empty.

IF PeriodLength = ZeroDateFormula THEN
  ERROR(Text001); 

Did my HOW TO help you? Leave a reply.

Exception from HRESULT 0x800AC472

Microsoft Dynamics NAV
—————————

Exception from HRESULT: 0x800AC472
—————————
OK
—————————

Exception from HRESULT 0x800AC472

Exception from HRESULT 0x800AC472

Solution:
Activate Microsoft Office Excel inserting the Product Key then close and reopen it.

Did my solution solve your problem? Leave a comment.

TableData does not exist

—————————
Microsoft Dynamics NAV Development Environment
—————————
TableData 404 does not exist.
—————————
OK
—————————

TableData 404 does not exist

TableData does not exist

Cause:
You are trying to import from a fob file an existing table in which was changed the value of the property DataPerCompany.

Solution:

  1. delete the Table with number as from the error message (in my case it was 404)
  2. import the object

Related Post: TableData 2000000001 does not exist.

Did my solution solve your problem? Leave a comment.

Method not found

Microsoft Dynamics NAV
—————————

Method ‘Page43.a60Action123a62_a45_OnAction’ not found.
—————————
OK
—————————

Method not found

Method not found

Solution:

  1. open in Design the Page as from the error message (in my case it was Page 43)
  2. press Ctrl+Alt+F4 or go in View -> Page Actions
  3. delete the value from the column “Name” (in my case it was Release)
  4. exit and save the object

Tips & Tricks: To find what is the action the error message is referring, in the message, after the word “Action” there is the value of the ID property (in my case it was 123)

Did my solution solve your problem? Leave a reply.

Root element is missing

Microsoft Dynamics NAV
—————————

This message is for C/AL programmers: A call to System.Xml.XmlDocument.Load failed with this message: Root element is missing.
—————————
OK
—————————

This message is for C/AL programmers: A call to System.Xml.XmlDocument.Load failed with this message: Root element is missing

Assumption:
You verified that the code you are going to load as XML is not empty.

Solution 1:
Verify that each tag has the corresponding closing tag

Solution 2:
Make sure that the stream Position is set to 0 (zero) before to load the Stream

IF stream.Position > 0 THEN
  stream.Position := 0;

Did my solution solve your problem? Leave a reply.