Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

xmlport can't insert new record in item table

Posted on by Microsoft Employee

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,

stack.png

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

*This post is locked for comments

  • Suggested answer
    SamCha Profile Picture
    SamCha 2 on at
    RE: xmlport can't insert new record in item table

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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans