Skip to main content

How to Create a Large Textbox in Business Central Using Control Add-ins

 If you’ve ever customized a page in Microsoft Dynamics 365 Business Central, chances are you’ve used the MultiLine = true property to enable multiline input for a text field. While this setting technically allows multiple lines of input, it comes with a limitation: you’ll only see about three lines before a scrollbar appears. This isn’t ideal for users who need to enter or read larger blocks of text.

Fortunately, there’s a way to significantly improve this experience. By using a Microsoft-provided Control Add-in, we can embed a fully customizable HTML textarea element directly into a Business Central page. This gives us full control over its size, styling, and behavior—allowing a much more user-friendly and visually accessible text input area.

In this blog, I’ll show you how to implement this using a real-world example: adding a custom work description field to the Service Item Card page. Instead of being limited to a few lines, our new implementation comfortably displays up to 16 lines of text before requiring a scroll. 

🛠️ How It Works

To implement the custom large text area, we use the Microsoft.Dynamics.Nav.Client.WebPageViewer control add-in to render HTML directly inside a page. This allows us to inject a styled textarea with JavaScript logic to handle input changes.

pageextension 50089 MyExtension12 extends "Service Item Card"
{
    layout
    {
        modify("ARC Location of Service Item")
        {
            Visible = false;
        }
        addlast(Customer)
        {
            group(TBM_WorkDescriptionGroup)
            {
                Caption = 'Location of Service Item Custom';

                usercontrol(WorkDescUserControl; "Microsoft.Dynamics.Nav.Client.WebPageViewer")
                {
                    ApplicationArea = All;

                    trigger ControlAddInReady(callbackUrl: Text)
                    begin
                        IsReady := true;
                        FillAddIn();
                    end;

                    trigger Callback(data: Text)
                    begin
                        MyWorkDescription := data;
                        Rec."ARC Location of Serv Item Cust" := MyWorkDescription;
                    end;
                }
            }
        }
    }

    trigger OnAfterGetRecord()
    begin
        MyWorkDescription := Rec."ARC Location of Serv Item Cust";
    end;

    trigger OnAfterGetCurrRecord()
    begin
        if IsReady then
            FillAddIn();
    end;

    local procedure FillAddIn()
    begin
        CurrPage.WorkDescUserControl.SetContent(StrSubstNo(
            '<textarea Id="TextArea" maxlength="%2" style="width:60%%;height:75%%;resize: none; font-family:Segoe UI, Segoe, device-segoe, Tahoma, Helvetica, Arial, sans-serif; font-size: 10pt;" OnChange="window.parent.WebPageViewerHelper.TriggerCallback(document.getElementById(''TextArea'').value)">%1</textarea>', 
            MyWorkDescription, 
            2048));
    end;

    var
        MyWorkDescription: Text;
        IsReady: Boolean;
}

🔄 How the Triggers Work

To make the custom textbox work properly, there are two triggers you need to use:

  • ControlAddInReady – This runs when the control add-in finishes loading. It’s where we insert the HTML for the large textbox using the FillAddIn() procedure.

  • Callback – This runs whenever the user changes the text in the textbox. It takes the updated text, stores it in a variable, and saves it back to the record.

These triggers help keep the textbox and the record in sync, so whatever the user types is stored correctly in Business Central.

This small enhancement can significantly improve the usability of any page where users enter or read long descriptions. It’s especially valuable in scenarios like quotes, service records, or case notes—anywhere that clarity and readability are essential.

Rather than settling for the out-of-the-box text box experience, this approach gives you complete control over presentation and improves the end-user workflow.

Comments

Popular posts from this blog

How to Convert Objects from C/AL to AL ?

  How to Convert Objects from C/AL to AL ? The Txt2Al conversion tool allows you to take C/AL objects, which were created in Dynamics NAV or Business Central Spring 2019 (version 14), and convert them into the new .al format.  Exporting the objects from C/SIDE in a cleaned .txt format. Converting the objects to the new syntax.  Here, I will be using BC14 ( Business Central Spring 2019) Objects and will be converting Sales Credit Memo report from C/Al to AL.   The .al format is used when developing extensions for Dynamics 365 Business Central.  Converting the objects consists of following two steps: Expo rting the objects from C/SIDE in a cleaned .txt format We need to run the Dynamics BC14 Development Shell as administrator to export BC14 object in new syntax. Run the following command to export object in text file. Syntax Export-NAVApplicationObject   [-DatabaseName] <String>  [-Path] <String> [-DatabaseServer <String>] [-F...

Temporary Tables in Business Central

Temporary Tables in Business Central A temporary tab le is a temporary variable that holds a table. A temporary table is used as a buffer or intermediate storage for table data. You can use a temporary table just like you use a database table. The differences between a temporary table and a database table are as follows: A temporary table of data isn't stored in the database. It's only held in memory until the table is closed. The write transaction principle that applies to a database table doesn't apply to a temporary table. Today one of my colleagues addressed me with an issue: all the records are deleted in the sales price table while applying the original prices.  After Analyzing the Code, I found that the developer had missed setting  the  Temporary  property to Yes while declaring the variable, due to which the table was considered as a Physical table and deleted the data from the database.  In this post, I’ll address some common misconceptions and gi...