5006

Rename Any Record from Text Values

Basics
Medium
Pro
recordref
keyref
fieldref
rename

Rename Any Record from Text Values

Go-live cleanup week: consultants keep sending correction sheets like "depot MAIN-OLD should have been MAIN" — the new key values arrive as plain text, and the affected tables vary from sheet to sheet. Instead of writing one fix-up routine per table, you will build a single generic utility that renames whatever record it is handed, using the record's own key metadata.

Requirements

The starter ships three small sample tables — keep their fields and keys unchanged and include all files in your submission, because the grading tests seed and read them:

  • Depot — single-field primary key "Depot Code": Code[20], plus Name and City.
  • "Depot Zone" — two-field primary key "Depot Code": Code[20], "Zone Code": Code[10], plus Description.
  • "Depot Bin" — three-field primary key "Depot Code": Code[20], "Aisle No.": Integer, "Bin Code": Code[10], plus Description.

Create a codeunit named "Record Renamer" with one public procedure:

procedure RenameByValues(var RecRef: RecordRef; NewKeyValues: List of [Text])

Rules:

  1. RecRef arrives positioned on an existing record of some table; NewKeyValues holds the record's new primary-key values as text, in primary-key field order.
  2. Work from the record's own key metadata — the procedure must handle any table whose primary key has one, two or three fields, not just the sample tables. Grading tests rename standard Payment Terms and "Item Translation" records to prove it. Primary keys of more than three fields are out of scope and never tested.
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