How to write custom code in NAV 2013 R2 Report layout design?
You may want to add custom code to the RDLC report to do more actions than what's already provided with the report functions. So it gives you a base for extending your report functionalities which can’t programmed in NAV report design environment. You may want to add custom code to implement simple string manipulation task or sophisticated data access manipulation. So you can add custom functions to RDLC report and add references to functions in report controls. When the report is compiled, the control reference function are executed automatically. Additional assemblies may be referenced using the Report Properties dialog box or the Code Modules element in the report definition. The Report Properties dialog box can also be used to define custom functions. To define custom functions in the report definition, use the Code element.
How to add code to a report?
1. From Report Layout designer in Visual Studio 2012, click Report Properties.
2. On the Code tab, in Custom code, type the code.
What's the code that I can add?
In the Custom Code section, it won’t support the NAV programing language C/AL. Here you can do the coding in VB. And you can add class members only (properties, methods, fields) but you can't add classes because these members are encapsulated in a class at runtime, this class called Code class.
For example, if you want to convert a string in to upper case letters, then you can write coding as per below screen shot.
You can use this code as expression inside a textBox or a table column as following:
The method toUpper which converts the string field value to an upper case string value.
I hope this would help you to make use of Custom Code section in RDLC report design. If some part of the programming is not executable in NAV report design environment, then we can utilize this Custom Code section.
If you wish to discuss further on this topic, please feel free to drop me an email to firstname.lastname@example.org