MAXSTRLEN on unlimmited Text variables

It has probably been blogged or posted about, but I must have missed it.

While recording a How Do I video for the Address Integration Pattern I noticed that you cannot declare an address array without declaring the length.

Here is why:

If I declare an address array without specifying the length I get this error:

Arithmetic operation resulted in an overflow.



And this is the code:


Since MAXSTRLEN returns 2147483647, this function blows up.

Here is proof:


The max value for integer (int32) is 2147483647. Adding 1, is not possible.

This entry was posted in General and tagged , . Bookmark the permalink.

6 Responses to MAXSTRLEN on unlimmited Text variables

  1. Pingback: MAXSTRLEN on unlimmited Text variables - Mark Brummel - Author of Microsoft Dynamics NAV 2009 Application Design

  2. Natalie says:

    The MAXSTRLEN issue was mentioned first (?) in Kamil’s comment of Vjeko’s post: (however without mentioning the exact error message).
    Thanks for reminding me of this topic anyway 🙂


  3. Yes it’s easy to miss, in fact I just had the exact same error today. Don’t really understand why I didn’t get it before…


  4. Lee Wright says:

    Thanks for this. So is this not a bug in NAV 2015 as this is the standard code? And i assume we just take out the +1 part? Thanks


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s