XMLPort: OnBeforeInsertRecord is run twice

AK
Member Posts: 226
Hi all,
I'm consuming a NAV 2009 web service in another NAV 2009 database by redirecting the XML response to an XMLPort to import records. The target table is empty. There is no code in the XMLPort.
It appears that for certain records the ObBeforeInsertRecord is run twice, which results in the "the record already exists" error.
I save the XML response to a file and check that the records in question only appear once. They do.
Setting the XMLPort record element to temporary didn't help, as well as some "IF record.get(PrimaryKey) then currXMLport.SKIP;" in OnBeforeInsertRecord.
As I'm fairly new to XMLPorts I'm pretty sure I'm missing something obvious and any help would be appreciated.
Unfortunately the response has 10MB an is too large to post here.
I'm consuming a NAV 2009 web service in another NAV 2009 database by redirecting the XML response to an XMLPort to import records. The target table is empty. There is no code in the XMLPort.
It appears that for certain records the ObBeforeInsertRecord is run twice, which results in the "the record already exists" error.
I save the XML response to a file and check that the records in question only appear once. They do.
Setting the XMLPort record element to temporary didn't help, as well as some "IF record.get(PrimaryKey) then currXMLport.SKIP;" in OnBeforeInsertRecord.
As I'm fairly new to XMLPorts I'm pretty sure I'm missing something obvious and any help would be appreciated.
OBJECT XMLport 5315151 Artikel Import Webservice { OBJECT-PROPERTIES { Date=11.09.17; Time=12:48:44; Modified=Yes; Version List=; } PROPERTIES { DefaultFieldsValidation=No; Format/Evaluate=XML Format/Evaluate; DefaultNamespace=urn:microsoft-dynamics-schemas/codeunit/Test; UseDefaultNamespace=Yes; } ELEMENTS { { [{856F907C-FF78-41F4-923C-01A224C2BE3B}]; ;Envelope ;Element ;Text } { [{1116D3CA-D807-4A20-A8C4-57AA968B161D}];1 ;Body ;Element ;Text } { [{41017B74-0E93-453F-9213-BD3F46F23B5A}];2 ;ReadItems_Result ;Element ;Text } { [{DC532533-B59D-4555-A5CA-32FAD639F39A}];3 ;result ;Element ;Text ; MinOccurs=Once } { [{953DC4D1-5191-44C3-B7B7-1280D1848DF3}];4 ;ExportArtikel ;Element ;Table ; SourceTable=Table50008; Temporary=Yes; MinOccurs=Zero } { [{E64D2B94-57E9-49C8-991C-44F9CA43B4F1}];5 ;Nr ;Element ;Field ; DataType=Code; FieldValidate=No; SourceField=Test Artikel::Nr. } { [{431731D9-AA6E-45D6-BFCC-F6329A0921A2}];5 ;Nr2 ;Element ;Field ; DataType=Code; FieldValidate=No; SourceField=Test Artikel::Nummer 2 } { [{C5B3C344-5503-42CA-9BB5-B921D9AB0A12}];5 ;Beschreibung ;Element ;Field ; DataType=Text; FieldValidate=No; SourceField=Test Artikel::Beschreibung } . . . this goes on for a couple of dozen fields . . . { [{850BC55A-1323-4EB4-9198-030F92C5EF54}];5 ;ModellCode ;Element ;Field ; DataType=Code; FieldValidate=No; SourceField=Test Artikel::Modell Code } { [{8C5DE225-6493-4D0A-924D-4832ABF5D852}];5 ;PackageCode ;Element ;Field ; DataType=Code; FieldValidate=No; SourceField=Test Artikel::Package Code } } EVENTS { } REQUESTPAGE { PROPERTIES { } CONTROLS { } } CODE { BEGIN END. } }
Unfortunately the response has 10MB an is too large to post here.
0
Best Answer
-
Found the property PreserveWhiteSpace, which deleted the spaces in primary key numbers and made them identical.1
Answers
-
Hello,
One question:
Are you sure that the sourcefile does not have duplicate entries?
Also check this thread for skipping records.
https://forum.mibuso.com/discussion/20448/xmlport-import-tempory-table-currxmlport-skip
best regards,
Thomas Barbut0 -
Thank you for your advice. But I'm sure that there are no duplicates and skipping the records doesn't work. In the OnBeforeInsertRecord trigger I'm not able to get the record which NAV claims already exists.
Very weird, I' know.
May be there is a known bug which may relate to this?0 -
Found the property PreserveWhiteSpace, which deleted the spaces in primary key numbers and made them identical.1
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions