Good morning everybody,
I have started using NAV since a week, I'm stuck in a problem regarding the use of the report fields. In particular, I'm trying to modify an existing report (I have opened it and saved it with a different name and ID) adding for instance some new fields to the dataset. If I have understood well, the way to show a field in the Header section of the report is by exploiting a "hidden textbox" in which I can insert the "setData" method. Well, If I create a new textbox in the header and I modify the "Expression" giving the "=Code.GetData(x,y)" with an existing x, it works properly. But, when I try to insert a new field in the dataset and then I add it into the SetData, when I retrieve it into the textbox I cannot see it, it's not printed out. Unfortunately it's not clear this step, my questions therefore are: which is the correct method to print a general field created into the dataset into the header? What if I create a report without header/body section? Will I be able to avoid the SetData/GetData methods simply dragging and dropping the dataset filed into the report paper?
Thanks in advance and have a nice day
*This post is locked for comments
I have tried to do all the stuff suggested below, unfortunately I cannot show the element yet. In particular I'm referring to the "BilltoCustNo_SalesShipHdr" field in report 208. Since there's one field in the body BUT there's no reference into the SetData function, I've decided to add it manually. Then I've opened the hidden textbox -> Visibility -> F(x) -> and I've added Cstr(Fields!BilltoCustNo_SalesShipHdr.Value) and all the Chr(177) needed. Then I went to the header, created a textbox and as Expression I've set "=Code.GetData(numberOfField,1)" and obviously substituting "number_of_field" with the correct value, in my case 45. If I run the report it doesn't work, but if I change number (let's say 44 or 25 or whatever) it shows the correct parameter!!!! I don't know what to think about.
In the header of the report.rdlc file, create one or more text boxes to save the data from the hidden text box in the body section. For example, in report 206, a blank text box is in the header section. It has the following expression as the value of its Hidden property:
=Code.SetData(ReportItems!CustAddr.Value,1)
The first parameter in the SetData function call corresponds to the name of the text box in the body section. The second parameter corresponds to the group number.
Please see the following content in Microsoft Dynamics NAV 2016/2017 developer or IT pro
How to: Print Report Header Information on Multiple Pages
Yes if you don't want the field on the header and footer, you can just drag that field from the Report --> Data to the textbox but if you need that on the header then you need add that to the SetData Textbox and based on which location and group you have added you need to specify that in the GetData function.
In Headers and Footers in RDL Layout we cannot just add fields from the dataset. Instead, we must add the field to the Body of the report (but hide it), and then use the ReportItems! collection in the header to refer to the field in the Body.
More info here:
Sohail Ahmed
2
mmv
2
Amol Salvi
2