web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

Code.GetData vs. Fields.Value for RDLC reports

(7) ShareShare
ReportReport
Posted on by 18
Hi everyone. This might be a bit of a silly question, but it's one I keep asking more experienced partners and getting no definitive answers for, so I'm hoping some wizard here might be able to clear things up for me.
 
Ever since I started, I noticed a lot of the OOB reports in BC get the information in their header by first storing it all in an invisible textbox, then using the GetData function to retrieve individual values. This, to me, seems very inefficient: It makes reports harder to read, much slower to edit and it doesn't seem to have any meaningful impact in performance in my testing.
 
For a long time now, I've been adding information to report headers simply by retrieving the value from the dataset. Thus far, I haven't found any issues in this, but I do worry I'm doing something wrong. Could anyone explain why this doesn't seem to be the standard for report building? What are the benefits of using GetData over referencing the values directly?
I have the same question (0)
  • Verified answer
    Sohail Ahmed Profile Picture
    11,087 Super User 2025 Season 2 on at
    Code.GetData vs. Fields.Value for RDLC reports
    You're absolutely right — using Fields!Value directly in RDLC headers works fine and is much simpler. The reason Code.GetData is used in many OOB reports is because headers and footers in RDLC don’t have direct access to the dataset scope. GetData is a workaround to pass values from the body to the header by storing them in hidden textboxes.
     
    If your values render correctly using Fields!Value, you’re not doing anything wrong — it's just a cleaner approach when the data is accessible.
     
    ✅ Mark this answer as verified if it helps you.
     
     
  • YUN ZHU Profile Picture
    92,507 Super User 2025 Season 2 on at
    Code.GetData vs. Fields.Value for RDLC reports
    This is because the GetData method can obtain different header values. For example, sometimes there is no problem when printing one invoice, but when printing multiple invoices, only the header of the first invoice will be displayed if you don't use GetData.
     
    Hope this can give you some hints.
    Thanks.
    ZHU
  • Gerardo Rentería García Profile Picture
    23,574 Most Valuable Professional on at
    Code.GetData vs. Fields.Value for RDLC reports
  • Suggested answer
    Kamal Khakhkhar Profile Picture
    1,202 on at
    Code.GetData vs. Fields.Value for RDLC reports
    Hii There,
    as per GETData , Setdata is used to print value as per header in report can have different value as per body on that time we can use that .
     
    while using field value its make static logic. it will not work for more reports.
     
     
    If you found answer mark it answered.
     
    Thank You.
    Kamal Khakhkhar
  • Suggested answer
    Steven Renders Profile Picture
    5,668 Moderator on at
    Code.GetData vs. Fields.Value for RDLC reports
    Never get fieldvalues directly from the dataset in the header. Sohail is completely wrong here...
     
    The header/footer can not reference field values directly, only aggregates like: first, last, sum,...
    It might seem to work, but it will show the wrong data as from the second page.
     
    Using SetData/GetData the correct information is added in the body of the report, for every page, and then copied to the header/footer.
     
    The way GetData/SetData is implemented, the code, is terrible, and there are much better ways to do that, with that I totally agree. Microsoft, at the time, simply copied this from a blog post by a SSRS MVP, which  was meant as an example. If you know a bit about VB then there are much easier ways to program it using for example collections, dictionaries,...
     
     
     
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 4,202

#2
Nimsara Jayathilaka. Profile Picture

Nimsara Jayathilaka. 3,248

#3
Sumit Singh Profile Picture

Sumit Singh 2,893

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans