Injection-Proof Vendor Search
Procurement wants a lookup where buyers paste vendor names straight out of supplier spreadsheets — sometimes one name, sometimes a whole column of them. The first prototype pasted that text into a record filter, and the bug reports wrote themselves: searching for O'Connor & Sons crashes, searching for Import|Export GmbH returns two unrelated vendors instead of the right one, and 1..10 Logistics quietly matches vendors that have nothing to do with it. A filter string is a tiny query language, and pasting user text into one is AL's version of SQL injection.
Your job is a search codeunit where every character of a searched name is treated as data — never as filter syntax.
Requirements
Create a codeunit named "Vendor Search" with two public procedures:
procedure ExactNameFilter(SearchName: Text): Text
procedure ApplyNameSearch(var Vendor: Record Vendor; SearchNames: List of [Text])Rules:
ExactNameFilterreturns a filter expression for theNamefield ofVendor: when a caller passes your return value toSetFilteronName, exactly the vendors whoseNameequalsSearchNameremain visible — every character taken literally (|,&,..,<,>,(,),=,@and apostrophes included) and letter case ignored. Two vendors sharing the searched name both remain; a vendor whose name only an either/or, range or symbol-stripped reading would catch must not.
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
- 15 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.
Already on Pro? Sign in