5019

Persist and Reapply Filter Presets

Filtering
Easy
Pro
table
getview
setview
sorting

Persist and Reapply Filter Presets

The dispatchers on your project set up the same customer list every morning — sorted by name, narrowed to their own slice of customers — and lose all of it the moment the session ends. You are building the persistence layer for named filter presets: capture a record's entire view (its sorting and all its filters) as one text string, store it under a code, and reapply it on demand. And because stored presets outlive code changes, a preset can go stale — a view naming a field that no longer exists, or text that got mangled — and your manager must detect that cleanly instead of crashing with a raw parser error.

Requirements

Pick object IDs in the range 50100–50199, and reference other objects by name, never by ID.

Create a table named "Filter Preset" with exactly these fields:

  • "Code" of type Code[20] — the primary key.
  • "View Text" of type Text[2048].

Create a codeunit named "Filter Preset Mgt." with three public procedures:

procedure SavePreset(PresetCode: Code[20]; var Customer: Record Customer)
procedure ApplyPreset(PresetCode: Code[20]; var Customer: Record Customer)
procedure IsValidView(ViewText: Text): Boolean

Rules:

  1. SavePreset captures the current view of Customer — the sort key, the sort direction, and every filter — and stores it in the "Filter Preset" table under PresetCode. Store the text exactly as GetView(false) returns it: field numbers instead of captions, the form the documentation recommends for feeding SetView later, because captions change with translations.
The rest of the statement and 3 hints Unlock with Pro
ALBusiness Central 28.5
Pro
Pro problem

Solve it with Pro

You’re reading the opening of the statement. Pro unlocks the whole problem:

  • The full statement
  • Starter code in the browser editor
  • 12 grading tests, run on Business Central 28.5
  • 3 hints
  • The reference solution

Pro also opens all 92 Pro problems and lifts the daily limits on compile checks and submissions.

$10 / month
or $100 / year
Upgrade
This problem is part of Pro
Pro unlocks the full statement, tests, hints and solution. The code editor works on a computer.
Upgrade