Report SetData/GetData alternative

Mirvan
Member Posts: 7
I'm beginner in writing RDLC reports and I'm not sure if I understand all details of this awkward solution for transport data from "current" dataset line to page header or footer.
I made some trials with surprisingly simple result but I'm not sure if it will be functional in all cases.
Rewiew and comment ti please !
I made some trials with surprisingly simple result but I'm not sure if it will be functional in all cases.
Rewiew and comment ti please !
private shared SavedFields as object public function SaveFields(fields as object) as boolean SavedFields=fields return true end function public function GetField(FieldName as string) as object return SavedFields(FieldName).value end functionCalling is straightforward. Saving current line from hidden box:
=code.SaveFields(Fields)and retrieving of field with name MyField:
=code.GetField("MyField")
0
Comments
-
Ok, I found one drawback in my solution:
Function SaveFields saves reference to Fields object, not its contents and because report engine reuses this object during processing dataset lines, there is no option how to save contents of particular line from page or worse, there is no guarantee which dataset line will be there when calling GetField (usually from page header or footer).
Better solution should be to copy or clone object contents (all fields), but it seems to be difficult or impossible.
Do you have some idea ?
Thanks0 -
Finally, this method is definitely wrong. My doubts:Mirvan wrote:... there is no guarantee which dataset line will be there when calling GetField ...0
-
The accuracy of this functions depend on where you used SetData (SaveField).
For example you can check report 204 : Sales - Quote (Standard report).
Earlier MS used to call this function in cell value, but now moved to Hidden property.
If you call this function on group header (hidden cell), you can get accurate output to the report header.
Alternative :
There is a simple way without using Code functions.
1. Keep the data fields in the table (in group header), which you need in report header
Value : Fields!No_SalesHeader.Value
Name : Number_SalesHeader
Hidden : True
make group header repeat in every page
2. Refer above cell at the report header text object as : ReportItems!Number_SalesHeader.Value
refer from the NAME of the cell (not from the VALUE of the cell)
Good Luck !!!
:thumbsup:Lakshan Kulawansa
ERP Consultant - MS Dynamics NAV
https://lk.linkedin.com/pub/lakshan-vindana-kulawansa/37/2a2/5920 -
Indeed, it looks like that a dynamic access to the Fields or Parameters collection is still not possible. This drawback seems to last for over 10 years, already...
jameskovacs.com/2005/08/04/digging-deep-into-reporting-services/
This is mainly due to the fact, that Fields does not inherit basic methods from the Collection class (for what reason ever). So it is not possible to retrieve the field names from Fields. This inhibits the deep copy (cloning) of Fields to another public shared variable.
You might take a look at this:
https://massivedynamicsblog.wordpress.com/2015/11/15/getting-rid-of-setdata-and-getdata-in-rdlc-reports-of-ms-dynamics-nav/New kits on the blog: https://massivedynamicsblog.wordpress.com0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 321 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions