Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

XML Port how to insert data in more than one table

Posted on by Microsoft Employee

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

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,900 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,275 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans