web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Error message when importing data via XMLport

(0) ShareShare
ReportReport
Posted on by

Hi,

I have create an XMLport to insert Sales Headers into the database.

As I'm new to XMLport I used this walkthrough as basis:

https://msdn.microsoft.com/en-us/library/hh165768(v=nav.90).aspx

To run the XMLport I used the following C/AL code:

SalesOrderXmlFile.OPEN('C:\NAV_DATAIMPORT\NewSalesOrder.xml');

SalesOrderXmlFile.CREATEINSTREAM(XmlStream);

IsImported := XMLPORT.IMPORT(XMLPORT::Latest_Test, XmlStream);

SalesOrderXmlFile.CLOSE;

IF (IsImported = TRUE) THEN
  MESSAGE('The import from XML is complete.')
ELSE
  MESSAGE(GETLASTERRORTEXT);

I have one record in the test XML file for a Sales Header with no. TEST02 (we use manual numbering).

When I try to import an error is generated instead of the record being added to the database: "The Sales Header does not exist. Identification fields and values: Document Type='Order',No.='TEST02'". As inserting a record is exactly what I'm trying to accomplish this error doesn't make sense to me.

Any ideas?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    RockwithNav Profile Picture
    8,637 Super User 2025 Season 2 on at

    This Xmlport Latest_Test is made with Sales Header and Sales Line Table?

    If Yes then How Sales Order No is being generated, Is that manual OR via Number Series?

    Did you tried debugging?

  • Verified answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    What does the file contains? Have you tryed with debugger active? It could be a validation problem if you have other fields on the imported order. When creating a standard Sales Order manually, NAV first does an INSERT for the number, then performs MODIFY for other fields. Maybe on a trigger NAV checks for the sales header that here is not inserted again.

  • Community Member Profile Picture
    on at

    Hi Stefano,

    Your reply got me on the right track, thanks!

    I did indeed have other fields and as it turns out it was stuck on the two shortcut dimensions. They were correct, but for some reason it couldn't handle them. I resolved the issue by removing the validation requirement on those two fields. The data is inserted correctly and without error.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans