Customizing Report Layout Implementation in Codeunit 1

Reports can be run directly from the Dynamics NAV client or from C/AL code by calling the RUN, SAVEASWORD, SAVEASPDF, or SAVEASEXCEL functions. When a report is run, the application calls the following functions in codeunit 1 to determine which report layout to use on the report.

Function Call Flow

To use the correct report layout for a report at run time, the report layout functions in codeunit 1 are called according to following flow.

  • Before the OnPreReport Trigger trigger is invoked, the application calls the HasCustomLayout function.

    The HasCustomLayout function determines whether the report is currently set up to use a custom RDLC layout or Word layout, and then calls one of the following functions:

    • If the report is currently set up to use a custom RDLC layout, then the ReportGetCustomRdlc function is called after the OnPreReport Trigger is invoked.

      This function loads the proper RDLC layout and uses the layout to render the report.

    • If the report is currently set up to use a custom Word layout, then the MergeDocument function is called after the OnPostReport Trigger is invoked.

      This function loads the proper Word layout and renders the report based on the action from the report request page, such SaveAsPdf, SaveAsWord, SaveAsExcel, Preview, or Print.

    • If the report is not currently set up to use a custom Word or RDLC layout, then the built-in layout is used for the report.

Modifying the Report Layout Implementation

To modify the report layout implementation, you design the implementation and then add C/AL code to the functions in codeunit 1.

To modify codeunit 1

  1. In the Microsoft Dynamics NAV Development Environment, on the Tools menu, choose Object Designer.

  2. In Object Designer, choose Codeunit, and then choose codeunit 1 Application Management.

  3. Add a code to the HasCustomLayout, MergeDocument, and ReportGetCustomRdlc functions.

  4. Save and compile codeunit 1.

See Also

REPORT.RUN Function
SAVEASWORD Function (REPORT)
SAVEASPDF Function (Report)
SAVEASEXCEL Function (Report)
Designing RDLC Report Layouts
Designing Word Report Layouts