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)
2016-01-04 at 10:39
Thank you for your post!
Easier solution for seeing the setdata/getdata number reference for a field would be setting Visual Studio editor to show line numbers:
Visual Studio Tools/Options, expand “Text Editor”, expand “All Languages”, and select checkmark to Display section for option “Line Numbers”.
LikeLiked by 2 people
2016-01-04 at 01:38
You’re welcome! ☺
Yeah I know, hence the link to a post that describes that in the beginning. But this time I wanted to show how to access the setdata function if you don’t have access to visual studio.
2018-07-11 at 10:14
We made new GetData/SetData functions that utilize a Key/Value approach: You still do a large string concatenation and a single call to SetDict. But the string is structured like “CustomerNo” + Chr(177) + CStr(Fields!CustomerNo.Value) + Chr(177) + “CustomerName” + Chr(177) + CStr(Fields!CustomerName.Value) (and so on). The data is then stored in a Dictionary. The “Get” is then GetDict(“CustomerNo”).
The GetDict() returns “Dictionary is empty” or “xx not found in Dictionary” if there’s a problem.
The advantages are:
– Easy to convert the existing GetData/SetData to this system
– Can also run NEXT to the existing GetData/SetData (if you don’t have the time to make the whole transition)
– You can tell in the GetDict’s what you are getting (most useful in compound textboxes where you can’t name the textbox appropriately.
– ORDER DOES NOT MATTER. You can sort the data anyway you like in the SetDict() call. Insert one in the middle? No problem!
– Data not begin found is noticable in print-outs.