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")
Comments
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 ?
Thanks
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:
ERP Consultant - MS Dynamics NAV
https://lk.linkedin.com/pub/lakshan-vindana-kulawansa/37/2a2/592
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/