SBX - Search With Button

SBX - Forum Post Title

xmlport can't insert new record in item table

Microsoft Dynamics NAV Forum

Catia asked a question on 7 Jun 2019 8:34 AM

Question Status

Suggested Answer

Hi everyone,


So I've created a xmlport to import text data to item table and the record don't exist and my xmlport says it was added with success and then raise the error that the item with no '8020150083' already exits. So , so in my item table i see that NOTHING is being added to my table from my text file and there is no item with no 8020150083 like my txt file.

In my text file I have this information,

"8020150083" "TESTE NEW ITEM" "UNI" "8020" "802015" "4,8235" "4,82292" "23" "NAC" "500302081" "" ""

And I have my xml port like the image below and the code,

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

OnPreXMLport()

OnPostXMLport()
MESSAGE('Added %1 new items 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."Vendor No.",VendorNo);
EVALUATE(Item."Vendor Item No.",VendorItemNo);
EVALUATE(Item."Item Tracking Code", ItemTrackingCode);

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

EVALUATE(Item.Integrado, '1'); // LACT001

IF Item.INSERT THEN BEGIN
nbOfSuccess += 1;
MESSAGE('Item%1 added with success', No);
END ELSE BEGIN
nbOfError += 1;
currXMLport.SKIP;
MESSAGE('Item %1 already exist', No);
END

Reply
SamCha responded on 7 Jun 2019 2:06 PM
My Badges
Suggested Answer

Pretty sure the XMLPort does the insert, so when you do the Item.INSERT you are actually doing it two times.

Reply
SamCha responded on 7 Jun 2019 2:06 PM
My Badges
Suggested Answer

Pretty sure the XMLPort does the insert, so when you do the Item.INSERT you are actually doing it two times.

Reply

SBX - Two Col Forum

SBX - Migrated JS