Change the report layout at runtime

With Reports ForNAV, you can change the used report layout at runtime. This means that you can load a layout, which you have stored in a file or a blob field and use that instead of the default layout.

This feature was introduced because a ForNAV customer wanted to change the invoice layout based on the items or customer on the invoice. However, this can be used for a lot of other things too.

To use this feature, you simply add a couple of lines in your code to load the layout. In the code snippet shown below, a new layout is loaded from a file. This code was added to the OnInitReport trigger.

myfile.OPEN(‘c:\temp\50111.rdl’);
myfile.CREATEINSTREAM(myInStream);
ReportForNav.LoadRdlc(myInStream);
myfile.CLOSE();

Layouts loaded in this way can be created using the ForNAV Designer. You simply save the layout to an rdl file.