In this video, I show how to use a Selection Filter to allow users to select multiple records in a lookup operation, check it out:

In this video, Erik demonstrates how to implement multi-select functionality in Business Central using AL’s built-in GetSelectionFilter function. Instead of adding items to a sales order one line at a time, users can select multiple items at once and have them all added as new sales lines automatically — all in about 42 lines of code.
The Problem: One Item at a Time
Out of the box, Business Central requires you to add items to a sales order one by one. You create a new line, open the lookup, select an item, and repeat. If you need to add seven items, that’s seven separate lookups. Many customers have asked for a way to select multiple items at once and have them all appear as lines on the order. This isn’t part of the core product, but we can build it with a surprisingly small amount of code.
The Approach: AssistEdit and GetSelectionFilter
Rather than modifying or breaking the existing lookup behavior on the sales line, Erik takes a non-destructive approach: he adds an AssistEdit trigger (the three-dot button) to the “No.” field on the Sales Order Subform. This gives users an additional way to add items while preserving the standard single-item lookup.
Why AssistEdit?
Fields in Business Central can have three types of interactive controls:
- Lookup — the dropdown arrow for selecting a single value
- DrillDown — navigates to the data behind the field
- AssistEdit — the three-dot button (“…”) that triggers custom behavior
By using AssistEdit, we avoid interfering with the standard lookup while giving users a clear entry point for multi-select.
Finding the Right Page to Extend
Using the Page Inspector (Alt+Ctrl+F1), Erik identifies that the sales order lines live on the “Sales Order Subform” page. This is the page we need to extend. The “subform” naming is a historical artifact from the days when Business Central (then Navision) used forms instead of pages.
The Star of the Show: GetSelectionFilter
The key to this entire solution is the GetSelectionFilter() function available on list pages like the Item List. When you open the Item List in lookup mode, users can select multiple records using standard multi-select (Ctrl+Click, Shift+Click). After the user clicks OK, GetSelectionFilter() returns a filter string representing all selected records.
For example, if you select items 1000, 1001, 1100, and 1200, the function might return something like:
1000..1001|1100|1200
This is a standard Business Central filter expression that you can apply directly to a record variable using SetFilter. Once applied, iterating through the filtered records gives you exactly the items the user selected.
The Complete Solution
Here’s the full page extension that implements the multi-select functionality:
pageextension 50100 "Our subform" extends "Sales Order Subform"
{
layout
{
modify("No.")
{
AssistEdit = true;
trigger OnAssistEdit()
var
ItemList: Page "Item List";
Item: Record Item;
SL: Record "Sales Line";
LineNo: Integer;
begin
ItemList.LookupMode := true;
if ItemList.RunModal() = Action::LookupOK then begin
SL.Setrange("Document No.", Rec."Document No.");
SL.SetRange("Document Type", Rec."Document Type");
if SL.FindLast() then
LineNo := SL."Line No.";
Item.Setfilter("No.", ItemList.GetSelectionFilter());
if Item.FindSet() then
repeat
LineNo += 10000;
SL.Init();
SL."Document Type" := Rec."Document Type";
SL."Document No." := Rec."Document No.";
SL."Line No." := LineNo;
SL.Insert(true);
SL.Validate(Type, SL.Type::Item);
SL.Validate("No.", Item."No.");
SL.Validate(Quantity, 1);
SL.Modify(true);
until Item.Next() = 0;
CurrPage.Update(false);
end;
end;
}
}
}
Step-by-Step Walkthrough
1. Open the Item List in Lookup Mode
ItemList.LookupMode := true;
if ItemList.RunModal() = Action::LookupOK then begin
Setting LookupMode to true tells the page to display OK and Cancel buttons so the user can confirm their selection. We check that the user clicked OK (not Cancel) before proceeding.
2. Determine the Last Line Number
SL.Setrange("Document No.", Rec."Document No.");
SL.SetRange("Document Type", Rec."Document Type");
if SL.FindLast() then
LineNo := SL."Line No.";
Before inserting new lines, we need to know the current highest line number on the document. Sales lines use line numbers incremented by 10,000 to allow for insertions between existing lines. Note that this code is document-type neutral — it works on sales orders, invoices, quotes, and any other sales document type because we reference Rec."Document Type" dynamically.
3. Apply the Selection Filter and Loop
Item.Setfilter("No.", ItemList.GetSelectionFilter());
if Item.FindSet() then
repeat
LineNo += 10000;
SL.Init();
SL."Document Type" := Rec."Document Type";
SL."Document No." := Rec."Document No.";
SL."Line No." := LineNo;
SL.Insert(true);
SL.Validate(Type, SL.Type::Item);
SL.Validate("No.", Item."No.");
SL.Validate(Quantity, 1);
SL.Modify(true);
until Item.Next() = 0;
This is where the magic happens. The filter string from GetSelectionFilter() is applied to the Item table. Then for each item in the filtered set, we:
- Increment the line number by 10,000
- Initialize a new Sales Line record
- Set the document type, document number, and line number
- Insert the line (with
trueto run the OnInsert trigger) - Validate the Type as Item
- Validate the No. field with the item number (which triggers all the standard item-related logic)
- Set a default quantity of 1
- Modify the record to save the validated fields
4. Refresh the Page
CurrPage.Update(false);
Finally, we tell Business Central to refresh the subform so the newly created lines are visible to the user.
Discoverability and Alternatives
Erik acknowledges that the AssistEdit button (three dots) has a discoverability challenge — users need to know what it does. Some alternative approaches to expose this functionality include:
- Adding a dedicated action on the subform (e.g., “Add Multiple Items”)
- Placing the AssistEdit on the Type field instead, which could enable multi-select for different types (items, resources, etc.) using a case statement
- Adding it as a promoted action in the action bar for better visibility
Summary
The GetSelectionFilter() function is a powerful and clean tool for implementing multi-select in Business Central. It returns a standard filter string from a list page’s multi-selection, which you can apply directly to a record variable and iterate over. The entire solution is remarkably concise — about 42 lines of AL code — and doesn’t interfere with existing standard functionality. Whether you use it for items, resources, or any other entity, the pattern remains the same: open a list in lookup mode, grab the selection filter, apply it, and process the results.