How to display percentage sign (%) with MESSAGE in Dynamics NAV?

I would definitely ask this question as part of the interview process for Dynamics NAV developers (that is, if I had a chance to interview someone… ok, I should stop dreaming and come back to reality now). This question is quite good, because, you will know the answer only if you have encountered this question before.

Message Function

So, how to display percentage sign (%) with MESSAGE function in Dynamics NAV? For example, if you would try

MESSAGE(STRSUBSTNO('You have %1%2 right now.',15,'%'));
MESSAGE(STRSUBSTNO('You have %1%2 right now.',15));

you would get some interesting results (but not what you actually need):

Wrong Message - Line BreakWrong Message - Missing Percentage

After this, (the easiest way, of course, is to give up, right?) you might decide to use word “Percent” instead of sign “%” (which is a valid solution and I’ve seen this used many times). But, if you don’t like giving up, try something else! Well, to start with, you don’t really need STRSUBSTNO function in the message. Try calling MESSAGE function without STRSUBSTNO:

MESSAGE('You have %1%2 right now.',15,'%')

you will get:

Correct Message - %


This entry was posted in development, Dynamics NAV / Navision, functionality, Tips & Tricks and tagged , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *