Filter Tokens

When entering filter values in the filter pane in the Business Central web client, users can enter filter tokens [% + reserved word] that resolve to a filter value or a filter expression. The reserved word can be written in small letters or completely in capitals, or even be translated – more on that soon.

Unfortunately, there is no docs article to summarize all standard filter tokens. Instead, they are spread over the docs and GitHub, so here is my attempt to fill the gap. First, we will learn about all available filter tokens per data type, and then we will look at their implementation in code, followed by a link on how to add your own ones.

  1. Text or Code fields
  2. Date, Time or DateTime fields
  3. Implementation

Text or Code fields

ExpressionSupported fieldResult
%me or %userUser ID (not in system fields)All records that are assigned to you.
%companyany Code or Text fieldThe current company name.
%mycustomersCustomer No.All customers that are included in the My Customers list on your Role Center.
%myitemsItem No.All items that are included in the My Items list on your Role Center.
%myvendorsVendor No.All vendors that are included in the My Vendors list on your Role Center.

The expression may differ per client language: In German, you can use %meinedebitoren instead of %mycustomers – or both.

Date, Time or DateTime fields

There is a variety of date or time related filter tokens – however, mostly date fields are supported:

ExpressionDateDateTimeTime
%todayxxn. a.
%nowxOnly as %NOWOnly as %NOW (fixed in BC 24)
%workdatexxn. a.
%yesterdayxmissingn. a.
%tomorrowxmissingn. a.
%weekxmissingn. a.
%monthxmissingn. a.
%quarterxmissingn. a.

If you want Microsoft to add the missing filter tokens for DateTime fields, then vote for this BC Idea: Support filter tokens for DateTime fields

In earlier versions, translated filter tokens for date or time related fields used to work in every casing. Since BC 23 (or earlier, I do not know), this seems to be broken: At least for the German client language, the translated token must be written in capitals: %JETZT.

Implementation

The implementation is – again – spread over multiple places:

Base Application: codeunit 9150 “My Records Filter Sub.”

  • %mycustomers
  • %myitems
  • %myvendors

System Application: codeunit 58 “Filter Tokens Impl.”

  • %today
  • %workdate
  • %now
  • %yesterday
  • %tomorrow
  • %week
  • %month
  • %quarter
  • %user
  • %me
  • %company

You can also implement your own filter tokens: Adding Custom Filter Tokens.

One thought on “Filter Tokens

Add yours

Leave a comment

Blog at WordPress.com.

Up ↑

Design a site like this with WordPress.com
Get started