Categories
Dynamics NAV HOW TO Microsoft

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:

NameDataTypeSubtype
TestFileFile
IstreamInStream
XmlDocDotNetSystem.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.

Categories
Dynamics NAV HOW TO Microsoft

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

[sourcecode lang=”Cside”]
TESTFIELD("Starting Date Formula",ZeroDateFormula);
[/sourcecode]

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.

[sourcecode lang=”Cside”]
IF PeriodLength = ZeroDateFormula THEN
ERROR(Text001);
[/sourcecode]

Did my HOW TO help you? Leave a reply.