Quit, Break, SKIP, EXIT

One of my student asked the following question few days back and I just tried to answer them in simple language. You may already know those answer right.

“can u please tell me the diff. in quit/break/skip/exit in NAV & how to use it properly……..”

Just to answer your question –

1. Quit 

Quit can only be used in Report, Dataport or XMLport. (Like Currreport.quit). It quits (come out from) the report or dataport or XMLPORT. If some processing of data happened before the quit statement, all of those data manipulations will be reversed (rolled back).

2. Break

Break can be used in 2 places –

a. in any loop (repeat..until) – This statement will break the loop and come out of the loop without further processing. All the data manipulation before this statement will remain intact.

b. In a report or dataport or XMLport. This statement will take you out from any trigger (like on prereport, Onpresection etc)

3. SKIP 

SKIP is only used in Report / Dataport / XMLPORT. This statement skips the iteration of a dataitem.


EXIT normally used in functions / triggers to return a value. (say a function returns a numeric value –

Myfunction(integer A, Integer B) Integer—



Hope the above answer helps you. I will try to send a more detailed answer to you (with example) soon. Keep writing me your problems and ask ur freinds to send their problems to me too.

You can also send me a mail to snehanshu.mandal@gmail.com

Navision – How to find out Square Root / Cube Root?

We all know how to raise a number to the power n. Use the powerful nummeric function ‘Power’.NewNumber := POWER(Number, Power);
So Power(4,2) will result in 16.But how to find out the roots (square, cuber or nth root)?

Simple use the same Power function – And just change the ‘Power’ parameter of the function.

So to find out the square root of say 16, use

Power(16,1/2); This will result in 4

to find out the Cube root of say 8, use

Power(16,1/3); This will result in 2.

to find out the nth root of any number just use –

NewNumber := Power(Number,1/n);

How to indent multiple lines of code in Navision

What to do if you need to indent several lines of Code (Just because youmade the changes in code lately) in any Navision Object? Will you do it manually one line at a time?
Don’t despair. There is a simple way to do it –
To indent several lines of code, select those several lines and press TAB. The code indents with two spaces to the right, every time that TAB is pressed.
To indent several lines of code to the left, select those lines, and press SHIFT+TAB. This indents the code with one space to the left, every time that SHIFT+TAB is pressed.
Block indentation enables developers to indent several lines of code in only three keystrokes (one for highlighting the code and two for pressing SHIFT and TAB.)

How to Send SMTP mail from Navision Application

2 Steps to use it –
1. Setup the SMTP mail in Navision.
2. Use the functions avaliable in Codeunit 400 (SMTP Mail)
1. Setup the SMTP mail in Navision:
Go to Administration> IT administration > General Setup > SMTP Setup. The following screen will open –
You need a SMTP server address (IP or link). I have used my office SMTP server. If your SMTP server permits anonymous mailing, you can choose authentication as ‘Anonymous’ where you don’t need to mention any user id and password.
If your SMTP Server does not allow anonymous mailing, you need to choose authentication as ‘Basic’ and need to mention one valid User id and Password.

2. Use the functions available in Codeunit 400 (SMTP Mail) :

Once the setup is done, you can start mailing using the functions available in SMTP mail codeunit.
a) Take a new form and take a command button on it. On clicking of that button the mail will be send (Just for the example)
b) Take a global variable ‘SMAIL’ of data type ‘Codeunit’ and subtype ‘SMTP mail’ codeunit. This will give you the access to the functions available in that codeunit.
c) Now the actual code. Write the following code on ‘On Push’ trigger of the command button
SMAIL.CreateMessage(‘Snehanshu’,’snehanshu.mandal@gmail.com’,’snehanshu.mandal@gmail.com’,’Warning – Inventory’, ‘Item 50005 has a inventory below minimum inventory level’,FALSE);
[Syntax for the Createmessage function – Createmessage([sender’s name] ,[sender’s id],[recipient’s id or ids],[subject] ,[body line] ,[html formatted or not]]
SMAIL.AddAttachment(‘d:Sales Invoice.xlsx’);
MESSAGE(‘mail send’);
That’s it. Now click on the command button, and the mail will be sent to the recipients.
1. There can be multiple recipients. Just put them as comma separated text in the recipient parameter.
2. You can add more body lines using ‘AppendBody’ function.
3. You can also mark a CC or BCC copy of the mail using ‘AddCC’ ‘AddBCC’ functions.
If you are not sure about the SMTP server, just search in google how to use, rediffmil, Gmail or Hotmail or any other mailing system as your smtp server.

Do things differently

To start our discussion, let’s take a simple topic –

Few months back, in one of Orkut forum somebody had posted a problem as follows:

‘I have to pick out a digit from a code field. E.g. Code is ‘50123AD786′ n I have to select 7th character from this field How can this be done…’

You all know it’s simple and the common way to achieve this is:

Copystr([ur code variable],[position, say 7 for 7th position],[length, here for u its 1])

We have designed a new form here. Taken a new global variable called ‘Name’ of data type Text and inserted a text box to display the variable.

We also have written a single line code as per the above syntax to display the 7th character of the ‘Name’ in a message box.

Now, can we do it in not so common way?

Yes, we can if we know that a text string in Navision is nothing but an array of characters (literally). So here ‘Name’ variable is nothing but an array of its length and we can fetch out the 7th character of it by simply referring it as Name[7]. To validate it, let us change the code in the ‘OnPush’ trigger of the Button as below:

Message (FORMAT (Name [7]));

Why we needed a FORMAT command? Just because the message box can only display text not character.

Here I entered ‘Snehanshu Mandal’ in the text box and clicked on the button ‘Click me’. It’s displaying the 7th character of my name ‘s’.

Don’t you think it’s interesting?

How can we make working on Navision a FUN?

Hi friends! How are you doing?

Last month, I completed 6 ½ years working in Navision and was stumped by one of my junior’s question – Don’t you get bored while working with Navision after so many years? Big question.

People are getting bored very fast nowadays. But why? You get bored when –

1. Work is monotonous
2. Work can be monotonous when you know everything and there is nothing new left to learn
3. ‘Hey, I am doing the same form designing, report designing and data port designing’

Besides the above points, you will find plenty of reasons of why people are getting bored in Navision.

I think the answer lies in the approach you have towards Navision. Whether we are trying to solve a problem too technically or we are having a holistic approach to solve a problem? Again to have a holistic approach towards a problem, you need to be little experienced on Navision or you have a fair idea about Navision functional things. So the whole issue is little paradoxical.
Whatever may be the reason, here we are not to discuss the problem. Rather we are here to try & make working on Navision a little more enjoyable. And to make it enjoyable, the best thing is to do something new in Navision every day. Mind it, you can do something new only when you do not know everything but you know something of Navision to start with.

I am not here to teach you something new in Navision rather together we will search new things in Navision. Every day, we will discuss about one topic and if you feel interested, you are welcome to suggest me the future topic or contribute a new discussion. You are welcome to send the problem you are having in your implementation and together we will try to evolve most reasonable solution of it. When so many brains will work on the problem, definitely we will be able to achieve most suitable solution for the problem
So let’s wish ourselves happy learning of Navision.