Written by 7:31 am How-tos, Modern Business, Show me the code

Editing a Navision (or Business Central 14) RDL Custom Report Layout

Introduction

Navision is an ERP by Microsoft. Business Central is Navision’s successor.

RDL is a Report Definition Language by Microsoft. RDL is used by Navision and Business Central.

This text is about editing the layout of an existing RDL report in Navision and Business Central 14, using the Report Builder application. A tough mission.

Navision provides the RTC client, a Windows desktop application. It also provides the NAV Development Environment, another desktop application, for editing Navision Objects and source code. BC 14 provides both those applications.

Creating a Custom Report layout

Microsoft provides extensive documentation on how to create a copy of an existing report layout or create a brand new one.

It is not possible to edit a Built-in Report layout. The documentation suggests to create a new Custom Report layout based on a Built-in Report layout, as described in the previous link.

Selecting a Custom Report layout

The editing of an RDL Custom Report layout starts by opening the layout using the RTC client.

Go to Report Layout Selection list page and select the appropriate Company Name in the drop-down box.

Then select the row with the Custom Report layout to edit. It must be a Custom Report layout. After that click on the Custom Layouts button.

The Custom Report Layouts list page is shown. There maybe multiple Custom layouts for the same report here. Select the appropriate and click the Edit Layout button.

In case of an error message saying that the system cannot find a proper Visual Studio version, go to NAV Development environment, menu Tools | Options find the Use Report Builder setting and set it to Yes.

This action opens the Report Builder in a separate window and loads the Custom layout. Under the Report Builder window, on Custom Report Layouts page, a message box is displayed.

Custom Reports Layout page

After editing the layout in Report Builder, and closing the Report Builder window, Report Builder asks to save the changes. You should answer yes.

But that’s not enough. Report Builder saves the changes to an on-disk file. You should click the Yes button in the message box of the Custom Report Layouts page in order for the changes to be imported from that disk file to NAV/BC. Otherwise they are lost.

Report Builder

To say it politely, Report Builder is a very difficult to work with tool. Lets say you have to work with a layout as the following.

Report Builder layout

How data comes to all those expressions?

The GetData() mystery

Right click on a text box, to display a context menu, and then click on the Expression menu item. The Expression dialog box appears.

What is that =Code.GetData(5, 1) code? Where did it come from?

Close the Expression dialog and right click somewhere outside of the layout, to display a context menu, and then click on the Report Properties menu item.

The Report Properties dialog provides the Code option which leads to a VBScript code. Here is where that GetData() function can be found.

Here is the signature of that function.

Public Function GetData(Num as Integer, Group as integer) as Object

The first parameter Num refers to an index inside a group, denoted by the second parameter Group.

In order to find what these groups and numbers are, we have to examine the RDL layout as an XML file.

Indexes and Groups of Data

Close the Report Builder and return back to the Custom Report Layouts list page. In the Home tab click the Export Layout button and save the layout as an RDL file.

RDL is XML actually. Open the file with a text editor, such as Notepad++ or VSCode.

Now search for SetData and you’ll find one or more entries similar to the following.

	=Code.SetData(Fields!A_Constant_Defined_In_NAV_Caption.Value 
	+ Chr(177) + Fields!A_Global_Variable_Defined_In_NAV.Value 
	+ Chr(177) + Fields!TableName__FieldName.Value 
	+ Chr(177) + Fields!Sales_Invoice_Header___No__.Value 
	+ Chr(177) + Fields!Sales_Invoice_Header___Posting_Date_.Value 
	+ Chr(177) + Fields!TIME.Value,1)

The number 1 in the above denotes the Group. So the =Code.GetData(5,1) returns the 5th entry of the 1st Group, that is Sales_Invoice_Header___Posting_Date_.

Copy all those Code.SetData() entries to a text file, and you’re ready to go.

Tested on:

  • Business Central 14
(Visited 184 times, 1 visits today)
Share the Post
Last modified: May 19, 2022
Close