Issue with XMLPort importing CSV file

JustAnotherNavUser
Member Posts: 7
Morning all,
I've been beating myself up over this for a while.
I'm updating an XMLPort for NAV 2013 which will be importing a CSV file. All this is fine.
Now, the issue I'm coming across is that the client is wanting to ensure that current records don't already exist in this destination table when importing the file. The import file is of course allowed to contain many instances of the same Key 1 (below) as this is being imported to create a Warehouse Shipment document.
So, Key 1 will define that it's a line (and header will be created automatically) and can obviously be present on multiple lines on the import document. The bit that's going wrong is that Key 1 may well appear 1 week down the line in a different file. In this instance it must error. The import is coming to a staging table prior to a secondary routine creating the Warehouse shipments.
The file looks something like this:
The issue I'm having with my XMLport is that when I attempt to implement the check of 'Does Key 1 exist in the table already' it's falling over on line 2 of the import file.
However, upon throwing my ERROR() the first line is not visible in the database, as I'd expect.
With this in mind if I have something like this
and then;
How am I able to circumvent this and allow multiple occurrence of 'Key N' within the file and only check for duplicates that are already existing and have been committed to the database table?
Cheers.
EDIT: Never mind, complete balls-up on my side, after a bit of Rubber Duck Debugging I worked out the system was working correctly and I'd need an additional filter.
I've been beating myself up over this for a while.
I'm updating an XMLPort for NAV 2013 which will be importing a CSV file. All this is fine.
Now, the issue I'm coming across is that the client is wanting to ensure that current records don't already exist in this destination table when importing the file. The import file is of course allowed to contain many instances of the same Key 1 (below) as this is being imported to create a Warehouse Shipment document.
So, Key 1 will define that it's a line (and header will be created automatically) and can obviously be present on multiple lines on the import document. The bit that's going wrong is that Key 1 may well appear 1 week down the line in a different file. In this instance it must error. The import is coming to a staging table prior to a secondary routine creating the Warehouse shipments.
The file looks something like this:
Header 1 | Header 2 | Header 3 | Header N Key 1 | Value 1 | Disregard | This Key 1 | Value 2 | It is | unrequired Key 2 | Value 1 | for this | problem ... Key N | Value N | Still | unimportant.
The issue I'm having with my XMLport is that when I attempt to implement the check of 'Does Key 1 exist in the table already' it's falling over on line 2 of the import file.
However, upon throwing my ERROR() the first line is not visible in the database, as I'd expect.
With this in mind if I have something like this
MyXMLPort MyTable Element Table <MyTable><MyTable> KeyInImportFile Element Text KeyInImport File //I've tried this being a source type of 'Field' too.
and then;
SecondInstanceOfMyTable.SETRANGE(Key, KeyOnTable) IF SecondInstanceOfMyTable.FINDSET THEN ERROR(); //already exists.
How am I able to circumvent this and allow multiple occurrence of 'Key N' within the file and only check for duplicates that are already existing and have been committed to the database table?
Cheers.
EDIT: Never mind, complete balls-up on my side, after a bit of Rubber Duck Debugging I worked out the system was working correctly and I'd need an additional filter.
0
Answers
-
EDIT: I'm an idiot.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