XMLPort(Import) Skip the first line, AutoIncrement Property

mustafaAlsoufimustafaAlsoufi Member Posts: 7
edited 2020-10-08 in NAV Three Tier
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.


  • AlexeyShaminAlexeyShamin Member Posts: 67
    edited 2020-10-08
    Hello! Do you import Entry No from file?
    If no - Set field "Entry No." in trigger OnBeforeInsertRecord in XMLPort

    Table1 - Import::OnBeforeInsertRecord
    Table1."Entry No." := I;
    I += 1;

    To skip line use
    currXMLPort.SKIP when you read first line
  • mustafaAlsoufimustafaAlsoufi Member Posts: 7
    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 imported
  • AlexeyShaminAlexeyShamin Member Posts: 67
    I think you have record in testtable with "entry no." = 0.
    In init xml port trigger try to initialize "i" variable as:
    IF Testtable.Findlast then
    I:= testtable."Entry No.";
Sign In or Register to comment.