5024

A Filter the Caller Can't Break

Filtering
Medium
Pro
filters
scoping
customer

A Filter the Caller Can't Break

Your regional sales apps all get their customer data the same way: a helper hands out a Customer record already limited to one salesperson, and downstream code — reports, exports, cleanup jobs written by other teams — filters that record however it likes. Last month a cleanup job called Reset() on the record it had been handed and exported the entire customer table to one very surprised salesperson. A week before that, an "optimization" retargeted the record to a different salesperson with a plain SetRange.

The fix is a scope the caller cannot break, no matter what filtering calls they make afterwards — the way a page's own view filters sit out of reach of everything the user does in the filter pane, narrowable but never removable.

Requirements

Create a codeunit named "Customer Scope Guard" with one public procedure:

procedure ScopeToSalesperson(var ScopedCustomer: Record Customer; SalespersonCode: Code[20])

Rules:

  1. After the call, ScopedCustomer sees exactly the customers whose "Salesperson Code" equals SalespersonCode — counting, finding and iterating all respect the scope, and a salesperson with no customers yields an empty record set.
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
  • 8 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