Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV forum
Unanswered

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

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,584 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,864 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans