5018

A Change Auditor for Any Table

recordref
fieldref
reflection
generic-code
flowfields

A Change Auditor for Any Table

Compliance wants a plain answer to a plain question: between the version of a record we archived and the version we have now, which fields changed, and from what to what? Today the question is about customers; next sprint it will be about a custom table that does not exist yet. So a case Rec.TableNo of routine is off the table — you are going to write the comparison once, against the table metadata itself, and it has to keep working for tables you have never seen.

Requirements

The starter ships a buffer table "Field Change Buffer" ("Field No." Integer primary key, "Field Name" Text[80], "Old Value" Text[2048], "New Value" Text[2048]). Include it in your submission unchanged — the grading tests read your results through it.

Create a codeunit named "Record Change Auditor" with one public procedure, exactly this signature:

procedure GetChanges(OldRecRef: RecordRef; NewRecRef: RecordRef; var Changes: Record "Field Change Buffer" temporary)

Rules:

  1. Any table. The two references decide which table is being compared — your code must not assume any particular table, field list, or field numbering. Field numbers can have gaps (a table may define fields 1, 4, 7, 30), and that must not break or skip anything.
  2. Start clean. Whatever rows the buffer held when the procedure was called are gone afterwards; every call reports only its own comparison.
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
  • 11 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