A Business Central AL extension that provides a simple HTML-based text editor for editing BLOB fields containing text data. This implementation demonstrates how to create a reusable text editing interface for any BLOB field in Business Central.
This extension provides a lightweight solution for viewing and editing text stored in BLOB fields. It uses the built-in WebPageViewer control add-in to render an HTML textarea, enabling users to edit large text content directly within Business Central pages.
The core logic component that handles reading and writing text to BLOB fields.
Key Procedures:
EditBlobFieldText(RecordVariant: Variant; FieldNo: Integer)- Opens the text editor in edit mode for the specified BLOB fieldViewBlobFieldText(RecordVariant: Variant; FieldNo: Integer)- Opens the text editor in read-only modeReadBlobText(RecordVariant: Variant; FieldNo: Integer)- Reads text content from a BLOB fieldWriteBlobText(RecordVariant: Variant; FieldNo: Integer; BlobText: Text)- Writes text content to a BLOB field
Technical Details:
- Uses
Data Type ManagementandTemp Blobcodeunits for generic record handling - Supports UTF-8 encoding for international characters
- Reads and writes text using InStream/OutStream with LF separator
- Generates HTML textarea with configurable read-only state and maxlength attribute
A StandardDialog page that hosts the text editing interface.
Features:
- Uses
WebPageVieweruser control to render HTML content - Dynamic title based on the source record ID
- Captures changes through callback mechanism
- Returns edited content when user clicks OK
Initialization:
TextEditor.Init(TitleText, BodyText, GetTextArea(ReadOnly, BodyText));Extends the Customer table with a new BLOB field for storing text comments.
New Field:
- Field ID: 50100
- Field Name: "Customer Text"
- Type: Blob
- Data Classification: CustomerContent
Adds an "Edit Customer Text" action to the Customer Card page.
Adds an "Edit Customer Text" action to the Customer List page.
Action Implementation:
trigger OnAction()
var
TextEditor: Codeunit "Text Editor";
begin
TextEditor.EditBlobFieldText(Rec, Rec.FieldNo("Customer Text"));
end;- User Action: User clicks "Edit Customer Text" from Customer List or Customer Card
- Read Data: The codeunit reads existing text from the BLOB field using
ReadBlobText - Generate HTML: Creates an HTML textarea with the current content
- Display Editor: Opens the Text Editor page as a modal dialog
- User Edits: User modifies the text in the textarea
- Callback: Changes are captured via the WebPageViewer callback mechanism
- Save Data: When user clicks OK, the codeunit writes the modified text back to the BLOB field using
WriteBlobText
To implement this text editor for any BLOB field in your own extension:
tableextension 50100 "My Table Ext" extends "My Table"
{
fields
{
field(50100; "My Text Field"; Blob)
{
Caption = 'My Text Field';
DataClassification = CustomerContent;
}
}
}pageextension 50100 "My Page Ext" extends "My Page"
{
actions
{
addlast(processing)
{
action("Edit My Text")
{
Caption = 'Edit My Text';
ApplicationArea = All;
trigger OnAction()
var
TextEditor: Codeunit "Text Editor";
begin
TextEditor.EditBlobFieldText(Rec, Rec.FieldNo("My Text Field"));
end;
}
}
}
}TextEditor.ViewBlobFieldText(Rec, Rec.FieldNo("My Text Field"));- Business Central version supporting WebPageViewer control add-in
- AL Language extension for Visual Studio Code
- UTF-8 text encoding support
- Maximum text length is determined by the Text data type limit in AL
- Uses simple textarea without rich text formatting
- No syntax highlighting or advanced editing features
- Single-line paste operations use LF separator
- Has sizing issues when PageType StandardDialog is used
- Reusable: Works with any BLOB field on any table
- Generic: Uses RecordVariant for maximum flexibility
- Simple: Minimal dependencies, uses built-in control add-ins
- UTF-8 Support: Handles international characters correctly
- Read/Write Modes: Supports both editing and read-only viewing
All objects are within the TextEditor.TextEditor namespace to avoid conflicts with other extensions.
- Tables: 50100
- Pages: 50100
- Codeunits: 50100
- Page Extensions: 50100-50101
- Table Extensions: 50100
This is a sample implementation for educational and development purposes. Feel free to reuse the code with no limitation
Created as a demonstration of BLOB field text editing in Business Central AL.
Last Updated: November 23, 2025