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.
Answers
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 line
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 imported
In init xml port trigger try to initialize "i" variable as:
Testtable.RESET;
I:=1;
IF Testtable.Findlast then
I:= testtable."Entry No.";