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:
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.
Just save the layout with Ctrl+S, switch to the Development Environment and save the report with Ctrl+S before running it. Saving in the report designer will automatically ask if you want to load the layout from Visual Studio, and everything is ready for testing.
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.
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 desired function, but forget to double-click the command to 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.
This brings us to one of the really annoying things in Visual Studio:
The information level of the header section is 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 and 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.
Adding extra fields to the header is really annoying. The process is as follows:
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:
Now open the hidden expression again:
Now it is easy to find the index number.
Remember to Rename the field to reflect the content.
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.
One of the things I really don't like about NAV development is RDLC reports. So thanks, a lot of great tips for report development.
Thanks! Really neat tricks and hints!