Skip to main content
Microsoft Dynamics NAV forum
Unanswered

XML Port how to insert data in more than one table

editSubscribe (0) ShareShare
ReportReport
Posted on by UG Leader

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

Attachments

Helpful resources

Quick Links

New Blog Features Released!

Check out the new community blog features for viewers and authors…

Setting Up Knowledge Sources for Copilot…

Look at how configuring a comprehensive knowledge base is crucial…

Demystifying Copilot with Georg Glantschnig…

Industry experts answer burning questions directly from our amazing Community…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,126 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,646 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Featured topics

Product updates

Dynamics 365 release plans