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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

XML Port how to insert data in more than one table

(0) ShareShare
ReportReport
Posted on by

Hi everyone,

I'm trying to read a text file with this content

"8020100172" "Test" "UNI" "8020" "802010" "10" "10" "23" "23 EXIST" "FITO" "1236547896541"

And I'm trying to insert this information in table Item, Item Unit of Measure and BarCodes.

So my xmlport insert in Item table but nothing is added in the other two tables and no erro is show. How can I do this? Am I writing code in the wrong place or maybe need to setfilter on item no? I'm a little confused and all the example I've see is only to add in one table.

I feel like the code is being ignored and not being runned.

4331.stack.png

OnInitXMLport()
nbOfSuccess := 0;
nbOfError := 0;

OnPreXMLport()

OnPostXMLport()
MESSAGE('Sucess adding items %1 of %2', nbOfSuccess, nbOfSuccess+nbOfError);


Item - Import::OnBeforeInsertRecord()
EVALUATE(Item."No.",No);
EVALUATE(Item.Description, Description);
EVALUATE(Item."Base Unit of Measure", BaseUnitOfMeasure);
EVALUATE(Item."Item Category Code", ItemCategoryCode);
EVALUATE(Item."Product Group Code", ProductGroupCode);
EVALUATE(Item."Unit Cost", UnitCost);
EVALUATE(Item."Last Direct Cost", LastDirectCost);
EVALUATE(Item."Gen. Prod. Posting Group",GenProdPostingGroup);
EVALUATE(Item."VAT Prod. Posting Group",VATProdPostingGroup);
EVALUATE(Item."Item Tracking Code", ItemTrackingCode);
EVALUATE(Item."Sales Unit of Measure", BaseUnitOfMeasure);

Item.VALIDATE(Item."VAT Bus. Posting Gr. (Price)", 'NAC');
Item.VALIDATE(Item."Inventory Posting Group", 'PROD');

Item.VALIDATE(Item."Item Disc. Group",'ALL');

IF Item.INSERT AND CodBarras.INSERT AND "Item Unit of Measure".INSERT THEN BEGIN
  nbOfSuccess += 1;
  MESSAGE('Item %1 ADDED with success', No);
END ELSE BEGIN
  nbOfError += 1;
  MESSAGE('Error in item %1. Maybe already exists', No);
END


Item Unit of Measure - Import::OnBeforeInsertRecord()

EVALUATE("Item Unit of Measure"."Item No.",No);
EVALUATE("Item Unit of Measure".Code, BaseUnitOfMeasure);

IF NOT "Item Unit of Measure".INSERT(TRUE) THEN BEGIN
  MESSAGE('Error Item Unit of Measure', No);
END

CodBarras - Import::OnBeforeInsertRecord()
EVALUATE(CodBarras."Item No.",No);
EVALUATE(CodBarras."Barcode No.", Barcode);
EVALUATE(CodBarras.Description, Description);
EVALUATE(CodBarras."Unit of Measure Code",BaseUnitOfMeasure);
EVALUATE(CodBarras."Last Date Modified",FORMAT(TODAY));

IF NOT CodBarras.INSERT(TRUE) THEN BEGIN
  MESSAGE('Error in BarCode', No);
END


Item Unit of Measure - Import::OnBeforeInsertRecord()
EVALUATE("Item Unit of Measure"."Item No.",No);EVALUATE("Item Unit of Measure".Code, BaseUnitOfMeasure);
IF NOT "Item Unit of Measure".INSERT(TRUE) THEN BEGIN  MESSAGE('Ocorreu um erro a acrecentar na "Item Unit of Measure". Provavelmente o produto %1 já existe', No);END

*This post is locked for comments

I have the same question (0)

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans