Skip to content
Simplifying Data Filtering

Filter Token Master: Simplifying Data Filtering with Custom Tokens

Daniel Gorski
Daniel Gorski July 24, 2023
2 min read

In Business Central, there are several built-in filter tokens available, and users can also define custom filter tokens to suit their specific needs. Custom filter tokens can be defined in any language and are accessible across the application.

To add a custom filter token in Business Central, you need to do the following:

  1. Define the Token Word: Decide on the special word that users will enter as the filter token, such as "%mycustomers".
  2. Implement the Token Resolver: You need to define a handler that resolves the filter token to a concrete value at runtime. This handler will be responsible for providing the relevant values that match the token. For example, if the user enters "%mycustomers," the handler should resolve it to the list of customers from the "My Customers" list.
  3. Register the Custom Filter Token: Once you have defined the token word and implemented the token resolver, you need to register the custom filter token in Business Central so that it becomes available for users to use in the filter pane.

By leveraging filter tokens, users can perform complex filtering operations with ease, improving their productivity and the overall user experience within Business Central.

All you need to do is subscribing to the OnResolveTextFilterToken Event in Codeunit "Filter Tokens.

In my example I'am using my own Salespersoncode from User Setup.

codeunit 50008 "ABC Custom Filter Token"
{
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Filter Tokens", 'OnResolveTextFilterToken', '', true, true)]
    local procedure FilterMySalesperson(TextToken: Text; var TextFilter: Text; var Handled: Boolean)
    var
        UserSetup: Record "User Setup";
        SPNTok: Label 'SPN', Locked = true;
    begin
        if not UserSetup.Get(UserId()) then
            exit;

        if UserSetup."Salespers./Purch. Code" = '' then
            exit;

        if StrLen(TextToken) < 3 then
            exit;

        if StrPos(UpperCase(SPNTok), UpperCase(TextToken)) = 0 then
            exit;

        Handled := true;
        TextFilter := UserSetup."Salespers./Purch. Code";
    end;
}

🔍 See it in Action!

Demo using custom token

Related posts

▸ All posts
Customizable cues in Business Central role center

BeyondCues: Custom KPI Tiles for Role Centers

January 27, 2024 · Daniel Gorski

BEYOND Cues adds configurable tabs to the Business Central role center, helping users navigate key metrics faster and work more productively.

Read More
Read More: BeyondCues: Custom KPI Tiles for Your Role Center
Extend barcodes with a few lines

Extend Beyondbarcodes with a few lines of code

October 04, 2023 · Daniel Gorski

This is our public repository where the source code is located:

Read More
Read More: Extend Beyondbarcodes with a few lines of code
BeyondCues automatic update feature

BeyondCues: Automatic Refresh Intervals for Cues

November 17, 2023 · Daniel Gorski

BeyondCues now supports automatic update intervals for Cues in your role center, ensuring always up-to-date business data—without manual refresh.

Read More
Read More: Introducing BeyondCues Automatic Update Intervals