I have previously written a blog post (Dynamics NAV Reports (RDLC): SetData, GetData And Line Numbers) that explains how to easier see which number a certain data has in the setdata/getdata functions by using Visual Studio and line numbers. Unfortunately the most guides on the net that deals with getdata/setdata functions takes for granted that you are using Visual Studio with document outline but sometimes that choice isn’t available. Hopefully after this blog post you will find it easier to find the setdata/getdata functions in the report, know where to add a new field. If you only want to see which number a certain field has. Scroll to the bottom and you will find a list of the fields and numbers.
I have divided this post into parts
- Find the SetData function call.
- Add a field to the SetData function call.
- Make the SetData expression more readable.
- A numbered list of all the fields in the SetData function call.
The example report that is used is report 206 Sales Invoice. The SetData function is the same in version 2013 R2 and 2015. Haven’t checked 2016 yet but I’m very sure it is still the same.
Find The SetData Function Call
Open the report layout with the report builder. Zoom on the marked part by using the slider or using CTRL +
Once you have zoomed you should look for this rectangle.
Left click on it to mark it and then right click to get the menu. Then choose the Text Box Properties.
Choose the Visibility setting and then look at the code for the expression.
Here you have the code for the setdata function call with all the fields as parameters.
Add A New Field With SetData
If you would like to add a field to the function call you have to add it at the end so you won’t displace the other fields from the correct order. Add it with the same syntax as the previous fields.
Make the SetData Expression More Readable
Unfortunately it isn’t very readable if you wan’t know which number CompanyInfoVATRegNo has.
To get a more readable list copy all the code in the expression from the Visibility settings to notepad. Now it is a little bit easier to read but the goal is to get a numbered list and we would like to accomplish this with the Import Text Wizard function in Excel. The idea is to convert the text into a CSV text. Start with search & replace according to the pictures (sorry for the Swedish captions).
Add the following to the last rows to make the CSV transformation complete.
After that we will cleanup the text a bit by deleting unnecessary text
After you have cleaned up the text. Copy all of it and open excel. Choose Paste/Use Text Import Wizard.
Format it as follows (again, sorry for the Swedish captions).
Now you have the data nicely in excel and you can format it so it becomes a nice list for future purposes.
The Final list
This is the final list to the SetData function call in invoice report 206. The version of the report is NAVW17.10,NAVSE7.10, from a Swedish 2013 R2 database. However I have compared this with a W1 2015 and they are identical except the last highlighted fields that are localized.
Code.SetData(CustAddr1 CustAddr2 CustAddr3 CustAddr4 CustAddr5 CustAddr6 CustAddr7 CustAddr8 BilltoCustNo_SalesInvHdr VATRegNo_SalesInvHdr YourReference_SalesInvHdr No_SalesInvHdr HdrOrderNo_SalesInvHdr PostingDate_SalesInvHdr DueDate_SalesInvHdr Cstr(PricesInclVATYesNo_SalesInvHdr) Cstr(First(Fields!DocDate_SalesInvHdr) SalesPurchPersonName DocumentCaptionCopyText PaymentTermsDesc ShipmentMethodDesc CompanyAddr1 CompanyAddr2 CompanyAddr3 CompanyAddr4 CompanyAddr5 CompanyAddr6 CompanyInfoPhoneNo OrderNoText EMail HomePage CompanyInfoVATRegNo CompanyInfoGiroNo CompanyInfoBankName CompanyInfoBankAccNo PricesInclVAT_SalesInvHdrCaption InvNoCaption SalesInvPostingDateCptn BilltoCustNo_SalesInvHdrCaption CompanyInfoBankAccNoCptn CompanyInfoBankNameCptn CompanyInfoGiroNoCaption CompanyInfoVATRegNoCptn CompanyInfoPhoneNoCaption PageCaption ReferenceText SalesPersonText VATNoText SalesInvDueDateCaption DocumentDateCaption PaymentTermsDescCaption ShptMethodDescCaption EMailCaption HomePageCaption PlusGiroNoCaption CompHasTaxAssessCaption CompanyInfoRegisteredOffice CompanyInfoPlusGiroNo BoardOfDirectorsLocCaption , 1)