Categories
Dynamics NAV Microsoft

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
[sourcecode lang=”Cside”]
IF stream.Position > 0 THEN
stream.Position := 0;
[/sourcecode]

Did my solution solve your problem? Leave a reply.

Categories
Dynamics NAV HOW TO Microsoft

HOW TO change data for all Companies in NAV

HOW TO change data for all Companies?

You have different ways to complete this task, the choice depends from how many lines or Companies you have. In the following steps I will explain you how to change data for all Companies in C/SIDE using the CHANGECOMPANY Function (Record):

  1. Create a new ProcessingOnly Report using with the System Table 2000000006 – Company as Data Source of a DataItem.
  2. Declare a C/AL Globals Variable of DataType Record with the table that you need.
  3. Insert the following code in the OnAfterGetRecord trigger

    TO MODIFY

    [sourcecode lang=”Cside”]
    GLSetup.CHANGECOMPANY(Name);

    GLSetup.MODIFYALL("Allow Posting From", 010114D);
    GLSetup.MODIFYALL("Allow Posting To", 310114D);
    [/sourcecode]
    or

    TO DELETE

    [sourcecode lang=”Cside”]
    ChangeLogSetup.CHANGECOMPANY(Name);

    ChangeLogSetup.DELETEALL;
    [/sourcecode]

Here find another reading suggestion, this time in T-SQL: HOW TO run SQL query for multiple companies in NAV database

Did my HOW TO help you? Leave a reply.