Simplifying Data Filtering

Filter Token Master šŸ•µļøā€ā™‚ļø | Simplifying Data Filtering with šŸ˜Ž Custom Tokens! šŸ’”

Daniel Gorski
Daniel Gorski 24. Juli 2023
2 Min. Lesezeit

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

beyondit
tech
Business Central
Filter Tokens
Customization
User Setup
Codeunit
Modulare ERP-Architektur für skalierbare Unternehmenssoftware

Architektur

Mehr als nur Warenwirtschaft - die Landtechnik Lƶsung

ERP-Systeme wurden jahrelang als Monolithen verkauft. Die eigentliche StƤrke moderner Plattformen wie Business Central liegt jedoch in der ModularitƤt - und gen

ā–¶ Read More
Read More
BeyondCues Subscription Billing KPIs in Business Central

Product

Subscription Billing Meets Real-Time KPIs: BeyondCues Sub. Billing

MRR, ARR, ARPU und Churn Rate direkt im Role Center von Business Central - ohne AL-Entwicklung. BeyondCues Sub. Billing bringt Subscription-KPIs dorthin, wo Sie

ā–¶ Read More
Read More