XMLPort(Import) Skip the first line, AutoIncrement Property

mustafaAlsoufi
Member Posts: 66
Hello experts,
I'm trying to import a CSV file using XMLPort, please find the screenshot below on how my table looks like

The Entry No. is the PK
That's being said, I have a couple of questions regarding XMLPort(Import).
1) While importing I'm getting the following error unless I change the 'AutoIncrement' Property for the 'Entry No.' to yes then the problem would be solved but caused another issue which is the 'Entry No.' will keep being incremented after another import even if I deleted some/all of the fields in the table

performance-wise, should I keep the AutoIncrement Property Yes or No, and how could I fix the issue of resetting the Entry No. to be matched with the previous Entry No.
2) My second question, is there a way to ignore the first line in the CSV file IF there is a header in that file, if not import everything. If so, could anyone share the code with me, please?
Thanks in advance.
I'm trying to import a CSV file using XMLPort, please find the screenshot below on how my table looks like

The Entry No. is the PK
That's being said, I have a couple of questions regarding XMLPort(Import).
1) While importing I'm getting the following error unless I change the 'AutoIncrement' Property for the 'Entry No.' to yes then the problem would be solved but caused another issue which is the 'Entry No.' will keep being incremented after another import even if I deleted some/all of the fields in the table

performance-wise, should I keep the AutoIncrement Property Yes or No, and how could I fix the issue of resetting the Entry No. to be matched with the previous Entry No.
2) My second question, is there a way to ignore the first line in the CSV file IF there is a header in that file, if not import everything. If so, could anyone share the code with me, please?
Thanks in advance.
0
Answers
-
Hello! Do you import Entry No from file?
If no - Set field "Entry No." in trigger OnBeforeInsertRecord in XMLPort
Example
Table1 - Import::OnBeforeInsertRecord
Table1."Entry No." := I;
I += 1;
To skip line use
currXMLPort.SKIP when you read first line0 -
No I'm not importing the "Entry No." from a file.
On the other hand, I tried to add the code you suggested but unfortunately I'm still getting the same error. For some reason it seems that the Entry No. is not being incremented everytime a line being imported0 -
I think you have record in testtable with "entry no." = 0.
In init xml port trigger try to initialize "i" variable as:
Testtable.RESET;
I:=1;
IF Testtable.Findlast then
I:= testtable."Entry No.";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