Snapshot or Shared View?
A pricing simulation builds its working data in a temporary "Name/Value Buffer" record. The audit trail wants a snapshot — the rows exactly as they were at one moment, frozen forever. A live monitor wants a shared view — a second variable onto the very same data set, following every later change. A teammate implemented both with the same one-liner, Copy with ShareTable = true, and now the "snapshot" keeps changing after it was taken. Your job is to give each consumer what it actually asked for.
Record.Copy is the whole lesson here, and it has two very different modes. With ShareTable = true (both records must be temporary) the target does not receive data at all — it becomes a second handle on the same in-memory table, so every later insert, modify, or delete shows through both variables. Without ShareTable, Copy transfers only the current row's field values plus filters — it never duplicates a temporary data set, so it cannot produce a multi-row snapshot on its own: the target's own data set stays empty. A real snapshot has to be built row by row.
Requirements
Create a codeunit named "Buffer Copy Service" with two public procedures:
procedure TakeSnapshot(var Source: Record "Name/Value Buffer" temporary; var Snapshot: Record "Name/Value Buffer" temporary)
procedure AttachSharedView(var Source: Record "Name/Value Buffer" temporary; var SharedView: Record "Name/Value Buffer" temporary)Rules:
TakeSnapshotfillsSnapshotwith its own independent copy of every row currently inSource— sameID,Name, andValueon each row.- After
TakeSnapshotreturns, the snapshot is frozen: rows inserted into, modified in, or deleted fromSourcemust not change whatSnapshotholds. - Taking a snapshot only reads — every row of
Sourceis still there afterwards, unchanged. (MovingSource's current position while reading is fine; the tests only look at the rows.) AttachSharedViewmakesSharedViewa view ontoSource's own data set: a row inserted into or modified inSourceafterwards is visible throughSharedView, and a change written throughSharedViewis visible inSource— same data, two variables.Sourcearrives without filters, andSnapshot/SharedViewarrive empty — you don't need to clear or unfilter anything.- Everything is temporary; neither procedure writes to the database.
Pick object IDs in the range 50100–50199, and reference other objects by name, never by ID.
What the tests check
The grading tests seed a temporary "Name/Value Buffer" with generated values, call one of your procedures, then mutate the source (insert, modify, delete) and check both directions: the snapshot must still hold exactly the rows and values from the moment it was taken, and the shared view must follow the source — including a write made through the view showing up in the source. A snapshot taken with ShareTable = true fails the frozen-in-time tests; a snapshot taken with a plain Copy fails the very first test, because it holds no rows.
Learn More
- Record.Copy(Record [, Boolean]) method — what
Copytransfers with and withoutShareTable, and whyShareTabledemands two temporary records. - Temporary tables — how a temporary record variable holds an in-memory data set of its own.
- Record.FindSet([Boolean]) method — the standard way to walk every row of a record set.
- Insert, Modify, ModifyAll, Delete, DeleteAll, and Truncate methods — the write methods; on a temporary record they touch only the in-memory copy.