RSS

Dynamics NAV Reports: Find Getdata Function With Report Builder

21 Dec

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

  1. Find the SetData function call.
  2. Add a field to the SetData function call.
  3. Make the SetData expression more readable.
  4. 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 +
Report_Builder_SetData_1

Once you have zoomed you should look for this rectangle.

Report_Builder_SetData_2

Left click on it to mark it and then right click to get the menu. Then choose the Text Box Properties.

Report_Builder_SetData_3

Choose the Visibility setting and then look at the code for the expression.
Report_Builder_SetData_4

Here you have the code for the setdata function call with all the fields as parameters.
Report_Builder_SetData_5

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.
Report_Builder_SetData_13

Make the SetData Expression More Readable

Unfortunately it isn’t very readable if you wan’t know which number CompanyInfoVATRegNo has.
Report_Builder_SetData_6
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).
Report_Builder_SetData_7.JPG
Add the following to the last rows to make the CSV transformation complete.
Report_Builder_SetData_9

After that we will cleanup the text a bit by deleting unnecessary text
Report_Builder_SetData_8

After you have cleaned up the text. Copy all of it and open excel. Choose Paste/Use Text Import Wizard.
Report_Builder_SetData_10.JPG

Format it as follows (again, sorry for the Swedish captions).
Report_Builder_SetData_11.JPG
Now you have the data nicely in excel and you can format it so it becomes a nice list for future purposes.
Report_Builder_SetData_12

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)

 

 
3 Comments

Posted by on 2015-12-21 in Okategoriserade

 

Tags: , , ,

3 responses to “Dynamics NAV Reports: Find Getdata Function With Report Builder

  1. Damogran

    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”.

    Liked by 2 people

     
    • Capone

      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.

      Like

       
  2. Vincent Vancalbergh

    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.

    Like

     

Leave a comment

 
Kauffmann @ Dynamics 365 Business Central

A good programmer makes all the right mistakes.

The BC Docs Librarian

Tips and news for AL programmers

Stefan Maroń

Dynamics 365 Business Central

James Pearson

Thoughts about Dynamics 365 Business Central, Git, Azure DevOps, PowerShell, Automated Testing, Visual Studio Code...and maybe some other stuff

Roberto Stefanetti BLOG

MVP & MCT Microsoft Dynamics 365 Business Central, Powershell, Azure, SQL Server

JoeBrown

DevOps starts with culture!

Comments for DevOps ABCs Blog

Reflections from the ERP field

DevOps ABCs Blog

Reflections from the ERP field

Dynamics 365 Business Central for Partners

Reflections from the ERP field

Freddys blog

Learn something new... - then Teach someone!

Stefano Demiliani Technical Blog

Reflections from the ERP field

David Worthington's NAV Performance Blog

Micosoft Dynamics NAV Performance Testing & Optimization

Freddys Blog

Reflections from the ERP field

Marije Brummel Blog | Business Central, Azure and more...

Design Patterns, Performance, Clean Code

Vjeko.com

Ideas in the cloud

Goprowe AB

Reflections from the ERP field

ArcherPoint

Reflections from the ERP field

The NAV Viking´s Blog

- Sharing my experience in the Dynamics NAV world

Comments for

Reflections from the ERP field