Editor
The ToolBox code editor is a browser-based AL code editor embedded directly in the Business Central client. It provides syntax highlighting, IntelliSense, and program management features so you can write, save, load, and manage your scripts without leaving Business Central. This page covers the editor interface, its IntelliSense capabilities, keyboard shortcuts, and program management workflow.
The SourceEditor Control
The code editor is implemented as a custom control called SourceEditor and is rendered in the upper portion of the "Erik's ToolBox" page. When the page opens, the editor initializes with the AL language mode enabled, which activates syntax highlighting for AL keywords, operators, strings, and comments.
The editor occupies the left side of the page layout and is where you write all of your AL code. It supports standard text editing features including copy, paste, undo, redo, and text selection. Because it runs as a browser-based control, it works in any supported browser without additional plugins or extensions.
When you first open the ToolBox, the editor loads either:
- The first saved program if this is your very first time opening the ToolBox.
- The program marked as Default if one exists.
- An empty editor if no default program is configured.
A demo program is automatically created the first time the ToolBox is opened in an environment. This demo program shows basic record iteration, message output, and Excel integration.
IntelliSense Support
The editor includes IntelliSense -- context-sensitive code completion that suggests relevant items as you type. IntelliSense in the ToolBox is powered by the Business Central symbol data available in your environment and responds to several trigger patterns.
Default Suggestions: Keywords and Functions
When you are typing at the beginning of a line or in a general code context (and the cursor position is at column 3 or earlier), the editor offers suggestions from the standard AL language set. These include:
Control keywords: var, begin, end, procedure
Statement keywords: if, else, for, to, downto, while, do, repeat, until, case, of, exit, break, foreach
Boolean keywords: and, or, xor, not, in, true, false
Object keywords: page, codeunit, report, run, runmodal
Data types: text, code, integer, biginteger, boolean, date, time, datetime, decimal, char, byte, record, codeunit, dialog, option, guid, duration, dateformula, array[, list of [, dictionary of [, jsonobject, jsonarray, jsontoken, jsonvalue, instream, outstream
Built-in functions: message, error, confirm, format, evaluate, commit, strlen, strpos, copystr, delstr, strsubstno, strmenu, today, workdate, time, random, randomize, createdatetime, currentdatetime, dmy2date, date2dmy, date2dwy, dwy2date, dt2date, dt2time, normaldate, closingdate, calcdate, power, abs, round, arraylen, compressarray, copyarray, copystream, downloadfromstream, uploadintostream, startsession, createguid (and more — the function list is generated from the signature catalog, so it always matches the parameter hints)
Excel functions: exget, exset, exclear, exopen
Table Name Lookup
When you type the keyword record followed by a space and begin typing a name, the editor triggers a table name search. This searches all available tables in your Business Central environment whose names start with the text you have entered. Each suggestion shows the table name and its table number.
For example, typing record Cust displays suggestions such as:
Customer(Table 18)Customer Bank Account(Table 287)Customer Posting Group(Table 92)
You can select a table from the list to insert its name into your variable declaration.
Codeunit Name Lookup
When you type the keyword codeunit followed by a space, the editor suggests the supported standard codeunit subtypes (Math, Rest Client, Format Address, and so on). The list is built from the interpreter's codeunit enum, so any subtypes contributed by other installed apps appear automatically. See Codeunit Support.
Field Suggestions (Dot Trigger)
When you type a record variable name followed by a period (.), the editor detects that you are accessing a member of a record variable. It parses the source code to identify the variable's declared table type, then retrieves all fields from that table and presents them as suggestions.
Each field suggestion includes:
- The field name
- The field data type (e.g., Text, Integer, Decimal, Boolean, Option, Code)
- The table it belongs to
In addition to fields, the editor also suggests all available record methods after the dot:
locktable(), calcfields(), calcsums(), changecompany(), get(), reset(), isempty(), init(), insert(), modify(), delete(), deleteall(), validate(), filtergroup(), mark(), markedonly(), clearmarks(), setfilter(), setrange(), setcurrentkey(), ascending(), getfilter(), findset(), findfirst(), findlast(), find(), next(), count(), countapprox(), testfield(), modifyall(), transferfields(), istemporary(), changeenvironment(), and more
Method Suggestions (Parenthesis Trigger)
When you type a record variable name followed by an opening parenthesis (, the editor provides the same field and method list as the dot trigger. This supports scenarios where you are calling a method that takes a field as a parameter.
Option Value Suggestions (Double Colon Trigger)
When you type :: after an option field reference, the editor identifies the record variable, locates the option field, and presents all available option values for that field.
For example, if you have a Status field on a Sales Header with options Open, Released, and Pending Approval, typing SalesHeader.Status:: presents those three option values for selection.
Dialog Method Suggestions
When you type a variable name followed by . or ( and the variable is declared as a Dialog type, the editor suggests dialog-specific methods:
open()update()close()
Member Suggestions Behind Typed Variables
The same dot trigger recognizes the newer complex types and offers their member functions when you type a variable of that type followed by .:
- Codeunit variables — the member functions of the declared subtype (e.g.
Math.Sqrt(),
"Rest Client".GetAsJson()).
- Json variables — the members of
JsonObject,JsonArray,JsonToken, orJsonValue. - List and Dictionary variables — the collection members (
Add,Get,Count,Keys, …). - InStream and OutStream variables — the stream members (
ReadText,WriteText,Eos, …).
Each suggestion shows the parameter hint and return type. All member and function hints come from a single signature catalog, so completions never drift from the actual call shapes.
Syntax Highlighting
The editor applies syntax highlighting for the AL language. When the editor initializes, it calls SetLanguage('al') to activate the AL language mode. This highlights:
- Keywords in a distinct color (e.g.,
if,then,else,begin,end,var,procedure) - Strings enclosed in single quotes
- Numbers (integer and decimal literals)
- Comments (single-line
//comments and multi-line/* */comments) - Operators such as
:=,+,-,*,/,<>,>=,<=
Syntax highlighting makes your code more readable and helps you quickly identify structural elements and potential issues.
Editor Toolbar and Keyboard Shortcuts
The ToolBox page provides several actions in the toolbar for working with the editor:
| Action | Icon | Shortcut | Description |
|---|---|---|---|
| New | New | -- | Clears the editor and loads the default program template. Prompts for confirmation if you have unsaved changes. |
| Run | Start | F9 | Executes the current code in the editor. |
| Load | Form | -- | Opens the Programs to select and load a saved program. |
| Save | Save | -- | Saves the current code to the currently loaded program. Only enabled when a program is loaded. |
| Save As | Save | -- | Saves the current code as a new program with a name you specify. |
| Excel | Excel | -- | Opens the Excel data sheet for use with exget/exset functions. |
| Batch Processing | ExecuteBatch | -- | Opens the batch processing wizard using the current editor code as a library source. |
| Download Result Text | Download | -- | Downloads all text from the output window as a text file. |
| AI Providers | Setup | -- | Opens the AI Providers page where the provider for the ToolBox Agent is chosen. Reopen the page afterwards to activate the agent. |
Additionally, the editor provides a Full Screen link that expands the editor to fill the browser window, giving you more space for writing longer scripts.
The page also includes a Show output in console toggle. When enabled (which is the default), all message() output is captured and displayed in the console pane rather than appearing as modal dialogs.
When an AI provider with the ToolBox Agent toggle is configured, a ToolBox Agent FactBox appears next to the editor. The agent reads and rewrites the program in the editor, compiles and runs it, and looks up tables and fields on request. See Coding Agent.
Loading Saved Programs
To load a previously saved program:
- Click the Load action in the toolbar.
- The Programs page opens, displaying all saved programs.
- Select the program you want to load and click OK.
- The editor loads the program's source code from its stored code blob.
- If the program has an associated Excel sheet, the Excel data is also loaded.
- The page caption updates to show the program name.
After loading, you can modify the code and either save changes back to the same program or save it as a new program with a different name.
Saving Programs
Save
The Save action writes the current editor contents back to the program you most recently loaded or saved. This action is only available when a program name is active (displayed in the page caption). If no program is loaded, use Save As instead.
Save As
The Save As action creates a new program:
- Click Save As in the toolbar.
- A dialog prompts you to enter a name for the new program.
- Optionally, you can choose to include the current Excel sheet with the program.
- Click OK to save.
- The new program is created in the Program table with the code stored as a blob.
The Programs
Programs are stored in the Program table. Each program record includes:
| Field | Description |
|---|---|
| Name | The display name of the program (up to 50 characters). |
| CodeBlob | The AL source code stored as a blob field. |
| Shared | Whether the program is shared with other users. |
| Default | Whether this program loads automatically when the ToolBox opens. |
| WithExcelSheet | Whether an Excel sheet is saved with the program. |
| ExcelSheet | The Excel data stored as a blob field (when applicable). |
| AvailableForPublicUsage | Whether the program is available for non-admin users through the Run Programs page. |
| PublicPermissionSet | The permission set required to run the program via Run Programs. |
| Origin | Indicates where the program originated (local or from a remote sync). |
| Tenant | The tenant GUID associated with the program. |
| EnvironmentName | The environment name associated with the program. |
Programs are stored across all companies (DataPerCompany = false), so a program saved in one company is available in all companies within the same environment.
Program Storage Sync
If your ToolBox setup has Program Storage configured (in the ToolBox Setup page), your shared programs are automatically synchronized to a cloud or version-control backend. You can choose one of two backends:
- Azure Blob Storage -- each environment's shared programs are stored as a blob named after its NickName.
- GitHub -- each shared program is stored as an individual
.alfile under aPrograms/<NickName>/folder in a GitHub repository, giving you full version history for every save.
Either backend provides:
- Backup -- Your programs are backed up outside Business Central.
- Cross-environment sharing -- Programs can be shared between different Business Central environments that point at the same Azure Storage account or GitHub repository. Give each environment a distinct NickName so they pull each other's programs.
- Remote programs -- Programs synced from other environments appear in your Programs list with their origin (the source environment's nickname) and are treated as read-only remote programs.
Synchronization occurs automatically: shared programs are pushed when you save and pulled when you open the ToolBox page. For configuration details, see Program Storage in the Setup overview.
Unsaved Changes Protection
The editor tracks whether you have made changes since the last save or load. If you attempt to close the ToolBox page or start a new program while unsaved changes exist, the editor prompts you with a confirmation dialog: "Your changes are not saved, exit anyway?" This prevents accidental loss of your work.
Tips for Working with the Editor
- Start with a template. If you frequently write scripts with a similar structure, save a template program and mark it as Default. The ToolBox loads it automatically each time you open the page.
- Use IntelliSense for discovery. If you are not sure which fields are available on a table, declare a record variable and type the variable name followed by a period. The IntelliSense popup shows all fields and methods.
- Name your programs descriptively. Since programs are shared across companies and can be synced to Azure Storage, clear names help you find the right script quickly.
- Use the Full Screen mode. For complex scripts with many lines, the Full Screen option gives you a larger editing area and improves readability.
- Include Excel sheets when needed. If your script relies on Excel data (using
exget/exset), save the Excel sheet with the program so the data is available when you reload the program later.