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
Azure Communication Services SMTP with Scanner

Using Azure Communication Services SMTP with Your Scanner or Printer

Need to send scans via email from your office scanner? Azure Communication Services provides a reliable SMTP relay that works with any device supporting SMTP au

ā–¶ Read More
Read More
XRechnung Einrichtung in Business Central

XRechnung in Business Central einrichten: Schritt für Schritt zur E-Rechnung

Ab 2025 wird die E-Rechnung im B2B-Bereich in Deutschland Pflicht. Wir zeigen Ihnen, wie Sie XRechnung in Business Central einrichten – mit E-Beleg-Dienst, Work

ā–¶ Read More
Read More