In the client, when filtering lists utilizing the filter pane, users can enter the D365 Business Central Filter Tokens, which are special words that resolve to one or more values. This powerful feature makes filtering simple by reducing the need to navigate to other pages to look up values to enter as filter criteria.
There are several useful filter tokens available in Business Central. For example, entering %mycustomers in a Customer No. field will rectify to the set of customers in the users My Customers list such as
1001|1002, making it easy to find relevant sales orders for customers 1001 and 1002.
You can insert custom filter tokens and make these accessible in any language and across the application. To insert your custom filter token, you need to describe the token word that users will enter as filter criteria and define a handler that resolves the token to a concrete value at run time.
D365 Business Central Filter Tokens Overview
Defining the Token Word and the Handler
To create the desired token word, start by defining a multi-language text string for your word. Subscribe to the
OnAfterMakeTextFilter events associated with the
MakeTextFiltermethod from the
In the event subscriber, if the value of the
TextFilterText parameter consists of the Microsoft Dynamics Business Central token string advance to process its value and construct the final filter string. If the filter string must consist of multiple values, you must handle the operators that joins them together, by inserting the
| filter symbol (OR operation).
Complete the operation by setting the value of the
TextFilterText parameter to the value of the final filter string. Filter criteria will often consist of symbols along with filter tokens. It is recommended that you only modify the filter token you have introduced and preserve the rest of the filter string.
This example shows how you can use the guidelines above to create the %MYTOKEN filter token. This will return a filter with the accounts marked as favorite by the user.
codeunit 50101 MyAccountFilterTokenSimple
[EventSubscriber(ObjectType::Codeunit, Codeunit::TextManagement, ‘OnAfterMakeTextFilter’, ”, true, true)]
local procedure FilterMyAccountsOnAfterMakeTextFilter(var Position: Integer; var TextFilterText: Text)
MyAccountTxt: Label ‘MYTOKEN’;
MyAccount: Record “My Account”;
if StrLen(TextFilterText) < 3 then
if StrPos(UpperCase(MyAccountTxt), UpperCase(TextFilterText)) = 0 then
MaxCount := 2000;
MyAccount.SetRange(“User ID”, UserId);
if MyAccount.FindSet() then begin
MaxCount -= 1;
TextFilterText := MyAccount.”Account No.”;
if MyAccount.next <> 0 then
MaxCount -= 1;
TextFilterText += ‘|’ + MyAccount.”Account No.”
until (MyAccount.Next = 0) or (MaxCount <= 0);
To try it out in the client, open the
Charts of Accounts page, filter on No. field, and type in a sub string that starts the same way with the chosen token word, like %MYTO. For more information on Microsoft D365 Business Central Filter Tokens, please contact us.