XMLPort to import variable field csv file - only bringing in two rows...?? (screenshots added)

I’ve got an XMLPort, Defined like this:

Root Text
SalesHeader Table (Sales Header) ← This is temp, code handles all inserts/updates
DataFileField1 Text
DataFileField2 Text
DataFileField3 Text

There are 30 fields in the file, 4 rows. I have no idea what’s going on, but when I step through the code in the VS debugger, it’s going through two lines then throwing this error:

The Sales Header already exists. Identification fields and values: Document Type=‘Quote’, No.=’’

Actually that error message isn’t caught by the debugger, it’s thrown in the RTC. My code is in the OnBeforeInsertRecord trigger and right now the only code in there is to increment a global record counter. Assuming I haven’t gone crazy, the XMLPort should run through OnBeforeInsertRecord 4 times and exit.

Anyone have any idea what’s going on here? I’ve been over the file format, data in the file, even completely changed the data in the file and nothing works. I’m at a loss as to why this is happening, also not sure why it’s trying to insert a Sales Header when the table variable is temporary…??

UPDATE: I just created a much simpler XML port with just 2 data fields and a data file to match. The same issue is occurring. If anyone is interested, I can provide those (XML port exported as text) and see if anyone else can see what’s going on. Here’s some screenshots:

It would be helpfull you can share the txt file also…

And the code in OnBeforeinsert trigger…

Here’s the contents of the datafile:

022300,SAIF-LR-6
022300,SAIF-MG-25
022300,SAIF-MG-25

And OnBeforeInsert:

SalesHeader - Import::OnBeforeInsertRecord()
RecordCounter := RecordCounter + 1;

The Primary key of Sales header table is Document Type,No. which you are not importing with your rxt file or not assigning in onbeforeinsert trigger.

so for first record it took Document Type as Quote (which is default option) and No=blank

when you try to insert second record it is trying to assign same above values and throwing error as record already existing…

either you have to import primary key values with txt file add the fields in xmlport designer or increment No. like recordcounter in onbeforeimport trigger…

Thanks!

Ok, this is where I’m confused. I thought if the data in the import file wasn’t relevant to the database, making the table element temporary basically prevents the XMLPort from importing into the “Sales Header” variable, relying instead on the programmer to do the insert.

Based on what you’re saying, even if there’s no relevance to the database in the data, I have to provide the key information for each row in the temporary “Sales Header” in OnBeforeInsert.

Am I understanding correctly?

Yes, you have to provide primary key fields to temporary table also…

That’s got it! You Da Man!!

Welcome [:)]