Clever Comments includes the ability to include comments on a small number of key documents as standard (See Including Comments on Documents for further information), however, many organisations use custom layouts or may wish to include comments on document types where this is not enabled as standard.

Clever Comments has been designed to be easily extendable with library functions to make it simple to include comments on further document layouts. 

Adding comments to RDLC Layouts

Step 1 - Create Report Extension

Note: This step can be skipped if adding a new layout to a report already amended by Clever Comments.

A report extension is required to add the comments fields to the existing dataset. A library function handles the retrieving and formatting the comments.

  • Create a new report extension that extends the report to be modified.
  • Add a variable for the library functions - Codeunit "Report Comment Mgt. CINSTMN".
  • In the dataset add a new field to hold the comments. This will be required for each level the comments are held at. For example, for a sales order confirmation, comments could be held against both the header and each line. For the Field Value call the function GetCommentsForRDLCLayout. This has two parameters, the first is the name of the dataitem in the report you are retrieving comments for, the second is a boolean that states if it is an external facing document (For example a Sales Invoice would be external, but a Pick Note may be internal).
  • Optionally, include The RDLC Layout that is a custom layout including the comment fields. 

The example below extends the Standard Sales Order Confirmation:

reportextension 50000 "Std. Sales-Order Conf. EXP" extends "Standard Sales - Order Conf."
{
    RDLCLayout = 'layouts/StandardSalesOrderConfWithComments.rdlc';

    dataset
    {
        add(Header)
        {
            Column(HeaderCommentsCCMTTMN; ReportCommentMgt.GetCommentsforRDLCLayout(Header, true)) { }
        }
        add(Line)
        {
            Column(LineCommentsCCMTTMN; ReportCommentMgt.GetCommentsforRDLCLayout(Line, true)) { }
        }
    }

    var
        ReportCommentMgt: codeunit "Report Comment Mgt. CCMTTMN";
}

Step 2- Create a Report Layout

  • Copy the existing report layout you wish to amend and open using either Microsoft Report Builder or Microsoft Visual Studio
  • Add a new Textbox to hold the comments in the relevant place on the report design
  • Check the textbox properties. As there could be multiple comments it is important that 'Allow height to increase' is enabled:

  • Right-click the placeholder and amend the placeholder properties. It is important that 'Interpret HTML tags as styles' is enabled otherwise the comments will not be formatted correctly.

  • It is strongly recommended that the visibility is set on the row (if the field is in a table) or the field itself to ensure there is no unnecessary white space on the report. This can be achieved by adding an expression as shown below:

Important: It is necessary to select the correct report layout in Microsoft Business Central in order for the comments to be displayed.

Adding comments to Word Layouts

Step 1 - Create Report Extension

Note: This step can be skipped if adding a new layout to a report already amended by Clever Comments.

A report extension is required to add the comments fields to the existing dataset. A library function handles the retrieving and formatting the comments.

  • Create a new report extension that extends the report to be modified.
  • Add a variable for the library functions - Codeunit "Report Comment Mgt. CINSTMN".
  • In the dataset add a new field to hold the comments. This will be required for each level the comments are held at. For example, for a sales order confirmation, comments could be held against both the header and each line. For the Field Value call the function GetCommentsForWordLayout. This has two parameters, the first is the name of the dataitem in the report you are retrieving comments for, the second is a boolean that states if it is an external facing document (For example a Sales Invoice would be external, but a Pick Note may be internal).
  • Optionally, include The RDLC Layout that is a custom layout including the comment fields. 

The example below extends the Standard Sales Order Confirmation:

reportextension 50000 "Std. Sales-Order Conf. EXP" extends "Standard Sales - Order Conf."
{
    RDLCLayout = 'layouts/StandardSalesOrderConfWithComments.rdlc';

    dataset
    {
        add(Header)
        {
            Column(HeaderCommentsCCMTTMN; ReportCommentMgt.GetCommentsforWordLayout(Header, true)) { }
        }
        add(Line)
        {
            Column(LineCommentsCCMTTMN; ReportCommentMgt.GetCommentsforWordLayout(Line, true)) { }
        }
    }

    var
        ReportCommentMgt: codeunit "Report Comment Mgt. CCMTTMN";
}

Step 2- Create a Report Layout

  • Copy the existing report layout you wish to amend and open in Microsoft Word
  • Show the Developer tab in the ribbon of Microsoft Word.

  • On the Developer tab, choose XML Mapping Pane.

  • In the XML Mapping pane, in the Custom XML Part dropdown list, choose the custom XML part for Business Central report, which is typically last in the list. The name of the custom XML part has the following format:

    urn:microsoft-dynamics-nav/reports/<report_name>/<ID>

    <report_name> is the name that is assigned to the report

    <ID> is the identification number of the report.

    After selecting the custom XML part, the XML Mapping pane displays the labels and field controls that are available for the report.

  • Place the cursor in the document where the control should be added.

  • In the XML Mapping pane, right-click the control that matches the new field added to the dataset in step 1, choose Insert Content Control, and then choose Rich Text Format.

Important: It is necessary to select the correct report layout in Microsoft Business Central in order for the comments to be displayed.

Note: Microsoft Word layouts do not support the same level of formatting as RDLC reports. In the initial version of Clever Comments some comment formatting will be removed if using comments with Microsoft Word report layouts.