XMLport import problem

roko
Member Posts: 16
Hello.
I use XMLport-s to import data from XML files into Navision. Sometimes the data in the xml files already exists in Navision datrabase. How can I tell the XMLport to insert only the non-existing records in the database.
Thank you in advance.
I use XMLport-s to import data from XML files into Navision. Sometimes the data in the xml files already exists in Navision datrabase. How can I tell the XMLport to insert only the non-existing records in the database.
Thank you in advance.
0
Comments
-
Hello,How can I tell the XMLport to insert only the non-existing records in the database?
Try: Make the SourceType Table Temporary, and then insert the records manually by code..CustRec := CustRecTmp; if NOT CustRec.insert then currXMLport.SKIP;
Met vriendelijke groet, best regards,
Rvduuren0 -
In which triger should I write this code?0
-
XMLPorts only know how to create records, at least I have not been able to get one to update existing ones. The standard behavior seems to be that it leaves existing records alone, so you would have to program it to update them. New records should just go right in.0
-
I don't want to update the records, like the behavior of the Dataports. I just want not to import the records which are already in the database, because I get "Record already exists" error.0
-
Then you use a record variable of the same type as the one you are importing, and you put something in the Import::OnBeforeInsertRecord trigger. Similar to Rik's example, but more like this:
IF TempCustomer.GET(<ID value from the Dataitem>) THEN currXMLport.SKIP;
0 -
I have thought about this solution, but I have 40 XMLports and if I have to add this code to every one, it will be very time consuming.0
-
It's two lines of code, most of which you can copy/paste. You can do 40 XMLPorts in less than half an hour. What do you mean time consuming?0
-
Nevermind.
Here is what I did for one ot the XMLports and it still gives me "Record already exists" errorDocumentation() OnInitXMLport() OnPreXMLport() OnPostXMLport() Document - Export::OnBeforePassVariable() Document - Import::OnAfterAssignVariable() ROW - Import::OnAfterInsertRecord() ROW - Export::OnPreXMLItem() ROW - Export::OnAfterGetRecord() ROW - Import::OnAfterInitRecord() ROW - Import::OnBeforeInsertRecord() IF UnitOfMeasure.GET("Unit of Measure".Code) THEN currXMLport.SKIP; Id - Import::OnAfterAssignField() Id - Export::OnBeforePassField() Name - Import::OnAfterAssignField() Name - Export::OnBeforePassField()
0 -
rvduuren wrote:Hello,
Try: Make the SourceType Table Temporary, and then insert the records manually by code..CustRec := CustRecTmp; if NOT CustRec.insert then currXMLport.SKIP;
If I make the SourceType Table Temporary, I can't export enything, because the Temporary Source Table will be empty when exporting.0 -
roko wrote:Nevermind.
Here is what I did for one ot the XMLports and it still gives me "Record already exists" errorDocumentation() OnInitXMLport() OnPreXMLport() OnPostXMLport() Document - Export::OnBeforePassVariable() Document - Import::OnAfterAssignVariable() ROW - Import::OnAfterInsertRecord() ROW - Export::OnPreXMLItem() ROW - Export::OnAfterGetRecord() ROW - Import::OnAfterInitRecord() ROW - Import::OnBeforeInsertRecord() IF UnitOfMeasure.GET("Unit of Measure".Code) THEN currXMLport.SKIP; Id - Import::OnAfterAssignField() Id - Export::OnBeforePassField() Name - Import::OnAfterAssignField() Name - Export::OnBeforePassField()
I have the same problem. The workaround I did was to delete the existing record on the Import::OnBeforeInsertRecord() trigger.
Did you find a better work-around?
thanks0 -
DenSter wrote:Then you use a record variable of the same type as the one you are importing, and you put something in the Import::OnBeforeInsertRecord trigger. Similar to Rik's example, but more like this:
IF TempCustomer.GET(<ID value from the Dataitem>) THEN currXMLport.SKIP;
Why the Command 'currXMLport.SKIP' does't work in the OnBeforeInsertRecord trigger?
The XmlPorts inserts the dataitem, cause the Onafterinsert-Trigger runs.
How can I solve the Problem without deleting before?0 -
Hello. I'm having the same problem. The CurrXMLport.SKIP seems to be ignored in any trigger I try. The table is set to a temporary table but it's trying to insert the records anyway. Any ideas?0
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