Getting rid of Setdata and Getdata in RDLC reports of MS Dynamics NAV

From the beginning I was not very satisfied with this Getdata-Setdata mechanism, which is proclaimed the standard way of displaying field values from the report body in the report header or footer of a NAV RDLC report layout. So I tried to find a more elegant way to accomplish this problem.
Consider report 205, Sales Order, of NAV 2015. One of the problems in this kind of reports is, that you want to print some fields of the sales header in the report header, which is normally not a dynamic header, but prints the same values on every page, by default. This is not too bad, if you always print only one sales order at a time. But the general case is the print of more than one sales order, may be with number of copies per sales order, too, but that doesn’t increase the complexity of the problem.
So how can we accomplish this scenario in an easy way?

As an example, I designed a sample report, which reveals the basic principles of the procedure. Here are the main steps:

1.) Report dataset:
Report Dataset
This is a simplified dataset for printing a sales order, which doesn’t contain any peculiarities.

2.) RDLC layout:
Report Layout
The layout contains the usual outer list for the pagebreak between each sales order (see standard reports).
Furthermore, there is one hidden textbox (yellow) at the beginning of the NewPage tablix, which looks at first glance quite similar to the setdata textbox of the standard report 205. But the main advantage is here, that it contains only one function call to a customer code function. This function call is as usual done in the hidden property of the textbox:
SetFields Textbox
The main difference is here, that all fields are evaluated in the SetFields function and there is no need, to list the fields explicitly as a concatenated string.

Now lets take a look at the Code of the report. In the first part, for every field, which is needed in the report header, a public shared variable is declared. In some cases (customer address), arrays are more easy to handle. These variables are filled with the corresponding values from the Fields collection in the function SetFields:
If another field has to be added to the header, the code has to be extended in a straightforward manner.

In order to get the values of the variables into the header, there is no need to use a kind of Getdata function, the public variables can be addressed directly in the textboxes of the header. For example:
Textbox Expression
That’s all. If you think, that was too easy, try it out yourself and enjoy how it works…

P.S.: A similar approach has been tried here:


4 thoughts on “Getting rid of Setdata and Getdata in RDLC reports of MS Dynamics NAV

  1. Pretty smart. Will try this next time. Do you usually copy standard reports like 206 or start from scratch? I mean, if you do the copying way, i.e. starting with a save as 206 to 50000, which is what I always do, do you run into any problems with this method?


  2. Another thing is how to add it to the end of an existing, standard Code.Setdata in order to not change the standard part that works already. These are Boolean operators, and I think this piece of s..t programming language Report Designer is using the same horrible VBScript we used to code in MS Access 143 million years ago, right? So in that case I think using the And logical operator, =Code.SetData(standard blahblah) And Code.Setfields could work … I must try this out.


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