Dataport Maximum length for Text is 20

I wrote a tab delimited import dataport and have a field in my NAV table that is Text50. I am importing data from a tab delimited text file that has 30 characters in this field and an getting the error: The text 'xxxx blah blah blah; is too ling. Text can have a maximum length of 20 characters.

I am not using any CAL code or variables, I basically built the dataport by selecting the table and adding fields via the dataport fields menu item.

Any idea what is going on here as it make no sense that if I am importing a 30 character field into a filed in a table that is 50 characters that I would get this error??

Kevin

Hi, run this through your debugger. I bet you are trying to import info into the wrong field. Check your mapping of fields being imported to the fields you have set up in your dataport.

As well as check the startpos and width field in Dataport Fields

It’s mapped to the correct fields as it runs fine if the field in question is less than 20 characters.

Also, Start pos and width are not used in variable dataports, only fixed.

I may have to set Global variables for the data files lengths which I would consider very poor on NAV’s part since I would think it would pull the data field lengths when you select the fields for the dataport items from the list of table fields.

Really frustrating.

Check whether you have used any variable

I’m not sure what that mean Amol, I have no CAL code used in the dataport and based on the Microsoft Documentation I should not need any. Are you saying I have to setup additional variables and it doesn’t care what the field size of the table is?

It’s hard to say without seeing your imported data or the fields you are trying to import to.

Perhaps your datafile has a bad tab - who knows.

You message tells you the problem “The text 'xxxx blah blah blah; is too long.”

So you have a problem somewhere.

For dataports I always prefer to Import into variables and map them back to there NAV fields OnAfterImportRecord trigger.

Gives more control on the order fields get imported & validating.

So for example if I was importing a field that had an item number.

I would create a variable “ImportItemNo” same type & size CODE 20 as the field it’s being imported to.

So in the"Dataport Fields" I would put my variable name “ImportedItemNo” instead of going directly to the table.

OnAfterImportRecord()

item.VALIDATE(“No.”, ImportedItemNo);

etc , etc ,etc with all the other fields (validating where needed)

Also allows you to use Currdataport.SKIP; if a condition arises where you don;t want that data imported aka already exists.

You can add messages and test string lengths, etc.