Managing layouts in code
When I introduced the report execution flow, I mentioned that the application code determines which layout needs to be used when. This flow starts from codeunit 1, application management, and uses several other tables and codeunits. If you spend a little time investigating this codeunit, then you will discover how you can use it to your advantage when you are confronted with managing report layouts so that you don't reinvent the wheel.
In codeunit 1, application management, and in the Custom Report Layout
and Report Layout Selection
tables, you will find many functions for managing reports and report layouts.
In codeunit 1, application management, there's a HasCustomLayout
function, that determines if a report has a custom layout or not, and if so, whether it's Word or RDLC:
// Return value: // 0: No custom layout // 1: RDLC layout // 2: Word layout IF ObjectType <> ObjectType::Report THEN ERROR(NotSupportedErr); EXIT(ReportLayoutSelection.HasCustomLayout...