Default Values on Insert
Every new customer must enter your onboarding pipeline, stamped with the date it was registered and an initial review status. Records are created from pages, APIs, and background jobs alike — so the defaults must be applied by the table itself, at insert time, not by any page.
Requirements
- Create a table extension that extends the
Customertable with two fields:"First Registered On"of typeDate"Review Status"of typeCode[10]
- Add an
OnBeforeInserttrigger that stamps defaults:- a blank
"First Registered On"(0D) becomesWorkDate() - a blank
"Review Status"('') becomesNEW
- a blank
- Values the caller has already set must be kept — only blank fields get a default.
The defaults must hold even when a field is explicitly cleared just before insert, so the InitValue property can't solve this one — the decision has to be made at insert time.
What the tests check
The grading tests insert customers with Insert(true) and read them back from the database: blank fields must come back as WorkDate() / NEW, and pre-set values must come back unchanged. They also check the declaration of "Review Status": a Code field (values stored uppercase) with a maximum length of exactly 10.
Learn More
OnBeforeInsert — it runs before the row is written, so your changes land in the database.0D for an empty date, '' for an empty code.OnBeforeInsert: assign WorkDate() only when the date is 0D, assign NEW only when the code is ''.