In Dynamics NAV reports we use SetData and GetData functions to retrieve data certain data in page headers and footers due to different scopes. In this blog post I’m not going to explain why and how but I’m going to give links to some good posts that does it at the bottom this post. Instead I’m going to give you a tip on how to make the process of adding/finding which data that has a certain index in the SetData function call by using line numbers.
In this example I’m using the report 206 “Sales Invoice” from Dynamics NAV 2015. Here you can see a typical GetData function call. Usually when you see this you wonder what the heck GetData(25,1) is and you start to curse Microsoft that they didn’t use place holder labels to make it easier for us (more about that later..).
So what are our options to find out which value 25 is? Well, one is to preview the report and hope that the example invoice contains a value in that field. The other options is to find the SetData function and start counting the rows until you hit index 29. This is how option two would look like. First we find the SetData function in report 206 (Dynamics NAV 2015) by using Document Outline in Visual Studio (Document Outline doesn’t exist in Report Builder). The SetData function call is located in the visibility expression.
As you can see you have to calculate each row until you have reached number 29. BUT! If you are using Visual Studio you can add line numbers to this view which will make it much easier. Unfortunately this is another function that doesn’t exist in Report Builder.
So how to get these line numbers then? Well, start by opening the Visual Studio options window (Tools/Options).
Then choose Text Editor/All Languages/General and then tick “Line Numbers” and now you have line numbers in your expression window. This tip originates from one of Claus Lundstrøm report classes.
Want to know more about GetData and SetData in Dynamics NAV reports? Here below are some good links that explains the concept behind it but beware, the placement of the SetData function call could be different depending of which version of Dynamics NAV you are running.
How Do I: Use SetData and GetData in Microsoft Dynamics NAV 2013 R2 [Movie]
Saurav Dhyani – RTC Report Development 3 (Dynamics NAV 2009)
One response to “Dynamics NAV Reports (RDLC): SetData, GetData And Line Numbers”