Tips on Developing Dynamics NAV Invoice Reports

Tips on Developing Dynamics NAV Invoice Reports

At my latest Development course, we went through the report designer in Visual Studio, and I realized that not everyone knows the little tricks that can make development much easier:

Don’t close Visual Studio

Closing Visual studio every time the report is tested, is wasting a lot of time. Visual Studio takes a long time to start and keeping it open all the time you save the time opening it again and again.

If you make changes to the dataset in the Development Environment, simply save the report in the Development Environment (uncompiled, if it doesn’t compile) and refresh the dataset in Visual Studio.

Keeping Visual Studio open also means that you keep all your undo information from since the object was opened.

Compiling the layout in Visual Studio

Often errors are not shown until the object is saved and compiled in the Dynamics NAV Development Environment. Some errors in the layout could be caught a lot earlier, simply by compiling the layout directly in Visual Studio.

A classic example is to click the desires function, but forget to double-click the command too include it in the expression.

The error given when the report is saved is this:

Instead the error could have been caught much earlier by clicking F5 (Debug) in the layout. That gives you the following error:

Which is the same but much earlier.

Document Outline

This brings us to one of the really annoying things in Visual Studio:

The information level of the header section if appalling. It is almost impossible to see what is hidden behind each field, and opening the expression does not make it any easier:

However, if you find the Name property of the field, you will find that the actual fieldname reflects the content of the field, in this case CustAddr6:

But it can be tedious to have to click on every field to find the desired field. Therefore, there is a window that can help, the Document Outline window:

It can be a little difficult to find, but it is only available in Visual Studio (not SQL Report Builder) and it is sometimes hidden under the menu View/Other Windows. The window shows all fields and objects in the layout.

Line numbering in the Expression property

Adding extra fields to the header is really annoying. The process is as follows:

  • Add the field to the dataset in the Development Environment
  • Save the field in the Shared Data1 variable with the SetData command
  • Find the index number that corresponds with the new variable
  • Create the field in the header with the correct name

Let’s try:

Add the Field to the dataset and save it.

Returning to the layout, the following message appears:

Now refresh the dataset in visual studio, and the new field appears:

Next find the Tablix containing the fields, the easiest way is to use the Document Outline window:

And open the Hidden property:

Over the years, I have done lots of different things to find the index number, but on my last course, Morten “The Fifth” from Skanderby in Ã…rhus gave this awesome trick:

  • Go to Tools/Options
  • Find the Text Editor/All Languages/General menu
  • Click the Line Numbers
  • Click OK

Now open the hidden expression again:

Now it is easy to find the index number.

Remember to Rename the field to reflect the content.

Find the properties without searching for the object

It can be difficult to find the object to select it in order to change the properties. The Document Outline window is one place but another is to select the object directly in the Properties Window:

I hope this will make things easier for you developing reports in the future.

Leave a Reply

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