Good afternoon all. We are finally upgrading our NAV form 3.7B to 2013. I have started to convert dataports to XMLPorts and just when I thought I had the hang of it, I ran into an issue. I searched the forum pretty extensively and followed the MSDN walk-thru, but I still have my issue.
I need to create an XML port that imports new Ship-to Address records for a given customer. Our staff populates a template file that is ultimately fed to NAV as a Tab delimited text file. The template contains a limited number of fields:
Code, Name, Name 2, Address, Address 2, City, County, Post Code, Country/Region Code, Contact, Phone No., Residential
When all the records have all the values, the XMLPort I created works fine. However, if some records have values in fields others don't, I am seeing NAV hold on to values and inappropriately apply them to the wrong records.
What?
Let me provide an example:
001 ShipTo 1 123 Any St Suite B Streetsboro OH 44241 US N
002 ShipTo 2 ShipTo 2 Name2 555 North Rd Streetsboro OH 44241 US 3306265555 Y
003 ShipTo 3 2690 15th ST Basement Cuyahoga Falls OH 44223 US Jason Larchmont 330-555-1212 N
DUDLEY The Cannon Group PLC 2 Lewes Road Dudley GA GB-DY5 4DJ US Bryn Paul Dunton N
PARK ROAD The Cannon Group PLC 10 Park Road Atlanta GA 31772 US James van Eaton N
Above, address 001, 003, DUDLEY, and PARK ROAD have no "Name 2" value, but address 002 does (ShipTo2 Name2). When I execute the XMLPort, 001 is created as expected, however, 002, 003, DUDLEY, and PARK ROAD are all created with the Name 2 value of 002. Similar things happen with Address 2 and Contact.
I tried creating new variables in the XMLPort, initializing them (OnAfterInit record) and assigning each in the OnAfterAssignVariable trigger. When I watch the example above in debugger, I see my variable "sName2" cleared in OnAfterInitRecord, and repopulate with "ShipTo 2 Name2" as expected for address 002, but then the same thing happens for all the subsequent records (003 onward), as if NAV is not using the actual field value from the flatfile.
This was never an issue with our Tab delimited dataport in the past. What am I missing? I'm sure there has to be a way to import record sets where some fields are populated and others aren't across the record set. Thanks!
kind of fell into this...
Answers
I have tried different formats (MSDOS, UTF-8), Preserve White Space Y/N, different delimiters, etc. and the result is always the same. The XMLPort does not seem to like null values (or single spaces) in the import flat file. Any advice is greatly appreciated.
I was using text elements to store the inbound values from the flat file (not field values). Then, OnBeforeInsertRecord for my Table element, I was assigning the text values to the NAV fields. I made a bad assumption that the text elements were automatically initialized per record (like with dataport fields). On OnAfterInitRecord for my table element, I added code to clear all of the text elements individually and this resolved my issue.
It would have been nice if the MSDN walkthru mentioned that.
](*,)