Skip to content

Conditional Layout Selections

Document Creator Conditional Layout Selections allow you to map conditions based on the contents of your report datasets to layouts that should be used when a (set of) condition(s) is/are satisfied.

Important

This feature is only enabled when reports are run with a Document Creator layout. For RDLC, Word and other layout types this feature is disabled.

Attention

We highly recommend to use a single layout with conditional visibility (e.g., using the VisibleExpression property) to show or hide sections/elements of your layout under certain conditions. This will considerably reduce maintenance costs for your layouts, when the layouts are almost the same, which is the case for the vast majority of all scenarios. We would advise to only use conditional layout selections if the layouts that you would like to use are considerably different!

Conditional Layout Selections

Conditional Layout Selections can be set up in the Document Creator Conditional Layout Selections page. In this page you can specify reports for which you wants to map conditions based on the report dataset's columns to a Document Creator layout when these conditions are met. With the Enabled field you also have the option to either enable or disable the layout mappings that you defined for the report.

Conditional Layout Selections

This page offers the following actions:

  • Layout Mappings - Set up mappings from conditions to a layout for the report (see Layout Mappings). The Layout Mappings flowfield will also show the number of conditional layout mappings that you have defined for the report.
  • Report Layouts - View or edit the Document Creator report layouts for the report.
  • Run Report - Run the report with a request page. You can use this action to see which layout is used when you run the report with certain parameters and filters.
  • Export - Export the conditional layout selections for the selected report(s) to an XML file.
  • Import - Import conditional layout selections from an XML file.
  • View Columns - View the columns of the report in a tree view. You can use this action to see which columns are available to use in your conditions (including custom columns added via the Dataset Extensions feature).
  • View Data Items - View the data items of the report in a tree view.
  • Dataset Extensions - View or edit the dataset extensions for the selected report.

Conditional Layout Selections Actions

Note

If there are zero mappings, then the Layout Mappings field is displayed in red.

Info

Layout selections take the following precedence:

  1. Design-time layout selection
  2. (Custom) Report selection layout selection (email body and attachment report layouts configured in the (Apportunix) Report Selection page(s))
  3. Conditional layout selection
  4. Run-time layout selection from the request page (Note: lower precedence as conditional layout selections are based on the report dataset, which is generated after the request page was opened)
  5. Layout selection
  6. Default layout (built-in, extension-provided)

Layout Mappings

On the Conditional Layout Mappings page you can map a (set of) condition(s) to a layout that should be used when the report is run. Here you can define one or more layout mappings, for which you can define conditions which, when satisfied by the report dataset, will make the report use a specific layout as configured for that scenario in the layout mapping record.

Conditional Layout Mappings

Each layout mapping record has the following fields:

  • Sequence No. - Specifies the sequence no. (starts at 1) for this conditional layout mapping, determining the order in which the layout mappings for this report will be processed. You can change this number to change the order of the layout mappings, if you wish that one layout mapping is evaluated before another. The layout of the first layout mapping whose conditions are met when the report is run, will be used as the layout for that report run.
  • Enabled - Specifies whether the conditional layout mapping is enabled.
  • Description - Specifies a description for this conditional layout mapping (optional). Here you can add an additional description so that you can further explain this conditional layout mapping to other users.
  • Layout Name - Specifies the name of the layout to configure the conditions for. If you create a new layout mapping record, this field will initially display Select Layout..., and if you drill down you can select a Document Creator layout that should be used when the conditions of this mapping are met.
  • Company-Specific - Specifies whether this conditional layout mapping only applies to one or more specific companies. If the value is Yes then this layout mapping will only be used when a report is executed from those companies. Note that you can view the linked companies in the Companies factbox and also view or edit them by drilling down on the field or using the Companies action. If the value is No (no companies are linked), then the layout mapping will be used in all companies. See also Layout Mapping Companies.
  • Conditions -Specifies the number of conditions configured for this layout mapping.

Note

If there are zero conditions, then the Conditions field is displayed in red and the layout mapping will never be used.

Note

Before you can edit the values on this page, you should first click on the Edit List action in the action ribbon.

This page offers the following actions:

  • Conditions - Set up the conditions for the selected layout mapping for the report based on the values of the columns in the report dataset (see Conditions).
  • Companies - Set up the companies to which the selected layout mapping for the report specifically applies. If the layout mapping should apply to all companies, then you should not enter any specific companies. See also Layout Mapping Companies.
  • Report Layouts - View or edit the Document Creator report layouts for the report.
  • Run Report - Run the report with a request page. You can use this action to see which layout is used when you run the report with certain parameters and filters.
  • View Columns - View the columns of the report in a tree view. You can use this action to see which columns are available to use in your conditions (including custom columns added via the Dataset Extensions feature).
  • View Data Items - View the data items of the report in a tree view.
  • Dataset Extensions - View or edit the dataset extensions for the selected report.

Conditional Layout Mappings Actions

Layout Mapping Companies

You can use the Companies action (or Company-Specific field's drill-down) to open the Conditional Layout Mapping Companies page. If you would like that a layout mapping is only evaluated when the report is run in specific companies, then you can enter these companies in this page.

Companies

If there are no companies listed in this page, then the layout mapping will be evaluated, no matter which company the report is run from.

Tip

You can also view the specific companies that are linked to a layout mapping by looking at the Companies factbox on the Conditional Layout Mappings page. This factbox shows the specific companies in which the layout mapping applies when the report is run.

Conditions

On the Layout Selection Conditions page you can set up conditions that should be met for a conditional layout mapping to be applied. On this page you can set up one or more conditions that specifies that the value of a column in the report dataset (the Condition Column) should match the value of either (1) a Constant Value (a fixed value), (2) the value of another column in the same context (the value of the Value Column), or (3) matches a specified filter (specified in the Filter String field).

Each condition record has the following fields:

  • Condition Column - Specifies a column from the report''s dataset to base the condition on. This can be a column from any data item in the report dataset, including custom columns added via the Dataset Extensions feature.
  • Value Column - Specifies the name of another column whose value the value of the condition column should meet to fulfill the condition. The value of this column can also be substituted in a filter by using a %1 placeholder in the Filter String field.
  • Constant Value - Specifies a constant/fixed value that the value of the condition column should meet to fulfill the condition.
  • Filter String - Specifies a filter string that the value of the condition column should meet to fulfill the condition. The filter string can also include a placeholder %1 in which the value column value or constant value will be substituted if either one is specified.
  • Fulfillment Method - Specifies the fulfillment method for this condition, i.e., which records should meet the condition for the condition to be fulfilled. For example, if you want to check that all sales lines of your sales document satisfy a condition you can put this to All, while if you want to check if there is at least 1 sales line that meets the condition you can set this to Any.

    Fulfillment Method Options

    • First - The column value of the first record should meet the condition.
    • Any - The column value of at least 1 record should meet the condition.
    • All - The column value for all records should meet the condition.

Example 1: Comparing against constant values

For our first example, we have two conditions that should be satisfied for the layout to be used when the report is run. With this example we would like to demonstrate how you can set up conditions that check column values against a fixed value.

Scenario: The "VAT Business Posting Group" should be equal to "EU" and Reverse Charge VAT applies for the sales order.

The first condition checks that the value of the (boolean) column ReverseChargeVATExists is equal to True.

The second condition checks that the value of the (text-code) column VATBusinessPostingGroup is equal to EU.

When we print a sales order for which both conditions are satisfied, the layout set up for this conditional layout mapping (with sequence no. 1) will be used.

Layout Selection Condition - Sample 1 - Constant Value

Example 2: Comparing against another column's value

For our second example, we have a single condition that should be satisfied for the layout to be used when the report is run. With this example we would like to demonstrate how you can set up a condition to check the value of one column against the value of another column.

Scenario: The "Bill-to Customer No." should NOT be equal to the "Sell-to Customer No." for the sales order.

The Condition Column used is the BilltoCustNo column.

Its value is compared to the value of the Value Column which is set to the SelltoCustNo column.

We want the values to be different (NOT equal), so therefore, we also enter the filter string <>%1 in the Filter String field where %1 is a placeholder for the value of the SelltoCustNo.

When the condition is evaluated, the value of the SelltoCustNo column will be substituted in the filter string's placeholder. For example, if the "Bill-to Customer No." would be 'C0100' and the "Sell-to Customer No." would be 'C0200', then the filter string will become <>C0200. In that case, the condition will be satisfied, as 'C0100' is NOT equal (<>) to 'C0200'.

Layout Selection Condition - Sample 2 - Filter Column

Example 3: Condition that needs to be met by at least one record

For our third example, we have a single condition that should be satisfied for the layout to be used when the report is run. With this example we would like to demonstrate how you can set up conditions that check if at least one record in the dataset satisfies the condition.

Scenario: There is at least one sales order line where the "No." field is equal to '1964-W'.

The Condition Column used is the No_2 column of the SalesLine data item, which contains the "No." field of the sales line.

The Constant Value field is set to 1964-W which is the fixed value we are comparing against.

The Fulfillment Method field is set to Any, so that the condition is satisfied if there is at least one sales line where the "No." field is equal to '1964-W' (which we entered in the Constant Value field).

When the condition is evaluated, it will check the value of the No_2 column for each sales line record until it finds a match with the constant value 1964-W. If we run the report for a sales order with two sales lines, the first with "No."='1976-W' and the second with "No."='1964-W', then the condition is satisfied by the second record and the configured layout is used.

Layout Selection Condition - Sample 3 - Any Record

Tip

You can change the layout of the page using the Personalize action in Business Central to add or hide fields that you would like to see on these pages, e.g., if you would like to see the Condition Column Data Item Name field, then it is available to add this way.

Example 4: Use custom columns in conditions

For our fourth example, we have a single condition that should be satisfied for the layout to be used when the report is run. With this example we would like to demonstrate how you can set up conditions based on custom columns that you add with the Dataset Extensions feature.

Scenario: There is at least one purchase order item line for which the "Inventory Posting Group" of the Item is set to "RAW MAT".

First, add a custom column (see Custom Columns for detailed information) called Inventory_Posting_Group_Item to the PurchLine dataitem.

To do this, first, create a Dataset Extension for report 11249681 "Purchase Order":

Sample 4 - Dataset Extension

Then, create a custom column, with parent data item PurchLine, from table Item, selecting field Inventory Posting Group:

Sample 4 - Custom Column

Then, set up the filters by choosing New under the Filter Set field, and set up the filters and restrictions as follows:

  • The "No." field of the Item table record should be equal to the value of the No_2 column of the PurchLine data item.
  • Only item lines should be considered, so a restriction is set up, to make sure the value of the TypeNo column is equal to 2 (= Item).

Sample 4 - Filter Set

Finally, make sure you save all changes of this dataset extension and then go ahead to set up the condition for your purchase order layout as follows.

The Condition Column used is the Inventory_Posting_Group_Item column of the PurchLine data item, which contains the value of the "Inventory Posting Group" field of the purchase order line's item.

The Constant Value field is set to RAW MAT which is the fixed value we are comparing against.

The Fulfillment Method field is set to Any, so that the condition is satisfied if there is at least one purchase order line where the value of the "Inventory Posting Group" field is equal to 'RAW MAT' (which we entered in the Constant Value field).

When the condition is evaluated, it will check the value of the Inventory_Posting_Group_Item column for each purchase line record until it finds a match with the constant value RAW MAT.

Layout Selection Condition - Sample 4 - Custom Column Condition

Example 5: Layout per responsibility center

For our fifth example, we set up sales invoice layouts for each of our responsibility centers and would like them to be used depending on the value of the Responsibility Center and Customer Posting Group field of the posted sales invoice.

Scenario:

We have set up three report layouts for posted sales invoices:

  • London Sales Invoice - We want this layout to be used when the Customer Posting Group is equal to "FOREIGN" and the Responsibility Center is equal to "LONDON".
  • Birmingham Sales Invoice - We want this layout to be used when the Customer Posting Group is equal to "DOMESTIC" or "EU" and the Responsibility Center is equal to "BIRMINGHAM".
  • Document Creator - Sales Invoice - The built-in (extension-provided) Document Creator layout for the Posted Sales Invoice, to be used by default when the conditions for the other layouts are not met.

First, add a custom column (see Custom Columns for detailed information) for (1) the Customer Posting Group of the posted sales invoice and (2) the Responsibility Center of the posted sales invoice.

Sample 5 - Custom Columns

Then, set up a conditional layout selection for report 11249662 Sales - Invoice and create two layout mappings, one for the London Sales Invoice layout, and one for the Birmingham Sales Invoice layout.

Sample 5 - Layout Mappings

Using the Conditions action, configure the conditions for the layout mappings accordingly:

  1. For layout mapping 1, for London Sales Invoice, for the first condition select Condition Column = Customer_Posting_Group_Sales_Invoice_Header and set Constant Value to FOREIGN, and for the second condition select Condition Column = Responsibility_Center_Sales_Invoice_Header and set Constant Value to LONDON.

    Sample 5 - Layout Conditions 1

  2. For layout mapping 2, for Birmingham Sales Invoice, for the first condition select Condition Column = Customer_Posting_Group_Sales_Invoice_Header and set Filter String to DOMESTIC|EU (N.B. this is an OR-filter), and for the second condition select Condition Column = Responsibility_Center_Sales_Invoice_Header and set Constant Value to BIRMINGHAM.

    Sample 5 - Layout Conditions 2

Finally, make sure your changes are saved and close the pages.

Now, we can check what happens for our three different cases:

  1. If we have a Posted Sales Invoice that doesn't meet the conditions for the layout mappings, then we get the built-in, default layout:

    Sample 5 - Output Example 1

  2. If we have a Posted Sales Invoice that meets the conditions for the first layout mapping, the London Sales Invoice layout, then the corresponding is used to generate the output:

    Sample 5 - Output Example 2

  3. If we have a Posted Sales Invoice that doesn't meet the conditions for the first layout mapping, but does meet the conditions for the second layout mapping, the Birmingham Sales Invoice layout, then the corresponding is used to generate the output:

    Sample 5 - Output Example 3


Last update: February 13, 2023