Scheduling filters and advanced filtering

Filters let scheduler users hide and show shifts, requests and workers directly in the calendar. You define filters as Custom Metadata records, so no code deployment is needed, and every filter is a small JavaScript object you control.

There are two flavors:

Both live in the filters side panel, participate in the Filter Logic expression, and appear as numbered summary pills in the header when active.

The calendar remains interactive while the filters panel is open. Scroll over the exposed calendar to move through scheduler rows; scroll inside the filters panel to browse its controls. No Salesforce configuration changes are required for this behavior.

Where filters are defined

Create records of b3s__Scheduling_Filter__mdt under Setup, Custom Metadata Types, Scheduling Filter, Manage Records.

Field Purpose
Label / DeveloperName Admin facing name of the record (not shown to users).
b3s__Javascript_Code__c A single JavaScript object literal that defines the filter (see below).
b3s__Order__c Sort order in the filters panel, ascending. The shipped filters use 1 to 10.

Every Scheduling Filter record in the org loads when the scheduler boots. There is no per app or per group assignment. To remove a filter, delete the record or do not deploy it. Ready made examples are included as sample b3s__Scheduling_Filter records with the package.

The filter object

b3s__Javascript_Code__c holds one JavaScript object literal:

{
    name: "shift-status",      // unique across all filters
    label: "Shift Status",     // heading shown in the panel
    type: 'shift',             // 'shift' | 'request' | 'resource'
    isDefaultOpen: true,       // optional: panel section starts expanded

    // EITHER items() ...........  standard checkbox filter
    // OR     inputs: [...] ......  advanced filter

    matchesItems: function (object, items) {
        // return true  -> keep the object visible
        // return false -> hide it
    }
}

The type property, what the filter hides

A filter never applies across categories. While evaluating a worker row, any active shift filters count as pass, and the other way round, so they stay neutral in the filter logic expression.

What matchesItems receives

The first argument is a calendar object:

The second argument is the current selection:

Variables available to your code

The snippet is evaluated inside the scheduler with these in scope:

Variable Contents
events All loaded calendar events (unfiltered).
screenEvents Events currently visible (after filters).
resources All worker rows, including currently hidden ones.
screenReources Worker rows currently visible (note the spelling).
viewName Current calendar view type.

Filters re-evaluate whenever data reloads, so items() can derive its options from events and stay current. Keep the code fast: it runs against every event on every filter run, and large datasets are processed in chunks with a progress bar.

Standard (checkbox) filters

Declare items() returning the checkbox list:

{
    name: "shift-status",
    label: "Shift Status",
    type: 'shift',
    isDefaultOpen: true,
    items: function () {
        // Distinct statuses from the loaded events
        const statuses = [...new Set(
            events.map(e => e.extendedProps?.record?.b3s__Status__c).filter(Boolean)
        )];
        return statuses.map(s => ({ name: s, label: s }));
    },
    matchesItems: function (event, selected = []) {
        return selected.includes(event.extendedProps?.record?.b3s__Status__c);
    }
}

Item properties: name (the value passed back in selected), label, optional color (checkbox border color) or classes (extra CSS classes, including configured colour classes such as bg-emerald-200). Items render in the order returned. A search box appears automatically when a filter has more than 5 items. Checking or unchecking applies immediately, and matchesItems is only called while at least one item is selected.

Advanced filters

Declare inputs instead of items. The panel renders the inputs plus Execute and Clear buttons, and nothing applies until Execute is clicked. On Execute all values are collected into one object and handed to matchesItems as items[0].

{
    name: "resource_distance",
    label: "Workers by Distance",
    type: 'resource',
    inputs: [
        { name: "address", type: "address", label: "Address",
          placeholder: "Search address..", required: true },
        { name: "distance", type: "select", label: "Within", default: "5",
          options: [
              { label: "1 km",  value: "1" },
              { label: "5 km",  value: "5" },
              { label: "10 km", value: "10" }
          ] }
    ],
    matchesItems: function (resource, items) {
        const values = items[0] ?? {};   // { address: {label,lat,lng}, distance: "5" }
        const record = resource.extendedProps?.record;
        if (!record?.Id) return true;    // keep the Unassigned lane
        // ... distance calculation, return true/false
    }
}

Input types

type Renders Value received in matchesItems
text text box string
select dropdown (needs options) the option value (always a string, Number(...) it if numeric)
multiselect checkbox list (needs options) array of option values
range slider with options: the selected option's value; otherwise a number, configured via min / max / step / unit
date native date picker "YYYY-MM-DD" string
time native time picker "HH:MM" string
address Google address search { label, lat, lng }, coordinates only exist when the user picked a suggestion

Common input properties: name, type, label, required, placeholder, default, options ([{ label, value }]).

Behavior notes:

One time setup for address inputs

Address search uses Google Places and needs an API key:

  1. Setup, Custom Settings, Scheduler Settings (b3s__Scheduler__c), Manage.
  2. Set Google Maps API Key (b3s__Google_Maps_API_Key__c) at org level, with the Places API enabled on the key.

Without the key, filters containing an address input show a warning and cannot be executed. All other input types need no setup.

Filter logic

Each active filter gets a number badge (1, 2, 3) in activation order. By default all active filters are AND-ed together. Users can enter a custom expression in the Filter Logic box at the top of the panel:

1 AND (2 OR 3)

Rules, same style as Salesforce report filter logic:

Filters of the other category (resource versus event) evaluate as true inside the expression for that target, so mixed logic like 1 AND (2 OR 3) works even when 1 is a worker filter and 2 to 3 are shift filters.

Shipped filters

Included in the Version 11 configuration downloads, deploy what you need. Version 11 sample DeveloperNames use a WFM_ prefix before the names shown below:

Filter Record Kind What it does
Shift Status Shift_Status_Filter checkbox One checkbox per distinct b3s__Status__c in the loaded shifts.
Job / Site / Job Group Shift_Job_Filter, Shift_Site_Filter, Shift_Job_Group_Filter checkbox Filter shifts by their job, site or job group.
Workers Resource_Filter checkbox Filter the worker rows by name.
Workers by Distance Resource_Distance_Filter advanced Address plus radius dropdown (1 to 15 km), keeps workers whose Contact MailingLatitude / MailingLongitude is in range.
Shifts by Distance Shift_Distance_Filter advanced Address plus distance slider, keeps shifts whose work site location is in range.
Available After / Before Time Resource_Available_After, Resource_Available_Before advanced Time input, keeps workers with no shift and no Unavailable request overlapping the rest of the day after (or before) that time.
Worker Availability Resource_Availability advanced Day (date picker, defaults to today), period (Morning / Day / Night / Full day) and Show mode. Not marked unavailable keeps workers with no shift and no Unavailable request in that window; Confirmed available only additionally requires an Available request overlapping the window. Built for fast same-day filling: hide everyone who can't work the selected day.
Time and Attendance Shift_Attendance_Filter checkbox Keeps shifts with the ticked attendance issue (see below). Ticking several keeps shifts with any of them.
Clock / Check-in Distance Shift_Attendance_Distance_Filter advanced Pick Clock in, Clock out and/or Check in plus a distance (500 m to 10 km), keeps shifts where any picked location is further than that from the work site.

Data prerequisites:

Time and Attendance filter options

Only assigned, non-cancelled shifts with a scheduled start are considered. Review these thresholds alongside the attendance reports. They are configured independently, including different check-in windows; to change a filter threshold, edit the numbers in the record's rules.

Option Keeps shifts that
Not checked in, starts within 60 / 120 min Require check-in (b3s__Check_In_Required__c), have no check-in or clock-in, and start within the next 60 or 120 minutes
At risk of lateness Start within the next 60 minutes, are not clocked in, and either still need a check-in or were checked in more than 5 km from the site
Late clock-in Were clocked in more than 5 minutes after the scheduled start
No show Have no clock-in more than 15 minutes after the scheduled start
Early clock-in Were clocked in more than 30 minutes before the scheduled start
Early clock-out Were clocked out more than 5 minutes before the scheduled end
Late clock-out Were clocked out more than 15 minutes after the scheduled end
Not clocked out after end Are clocked in, not clocked out, and the scheduled end has passed

The time based options compare with the current time when filters run, which is on load, background sync, save and view change. A shift crosses into a band at the next sync, not the exact minute.

These are shift filters: they hide shifts, not workers, so rows without a matching shift stay visible but empty.

Gotchas and tips