nerdexam
Microsoft

MB-500 · Question #73

Drag and Drop Question You are a Dynamics 365 Finance developer for a company that sells pre-owned vehicles. When the company acquires a new vehicle, vehicle identification (VIN) numbers are added…

The correct answer is Copy the validatedWrite event handler on the CustTable object.; Add the event handler method to a class.; Add code to perform the validation. Explanation: D365 Finance VIN Validation Event Handler Core Concept In Dynamics 365 Finance, you never modify base objects directly. Instead, you use the event subscription model - copying event handler stubs and placing them in your own extension classes. The sequence reflects…

Design and develop AOT elements

Question

Drag and Drop Question You are a Dynamics 365 Finance developer for a company that sells pre-owned vehicles. When the company acquires a new vehicle, vehicle identification (VIN) numbers are added to the VIN field in the CustTable. You need to create an event handler to validate that new VIN values are at least 10 characters long. Validation must occur when records are saved. Which three actions should you perform in sequence? To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order. Answer:

Exhibit

MB-500 question #73 exhibit

Answer Area

Drag items

Copy the onWriting event handler on the CustTable table object.Copy the validatedWrite event handler on the CustTable object.Add code to perform the validation.Copy the onModified event handler on the CustTable object.Add the event handler method to a class.

Correct arrangement

  • Copy the validatedWrite event handler on the CustTable object.
  • Add the event handler method to a class.
  • Add code to perform the validation.

Explanation

Explanation: D365 Finance VIN Validation Event Handler

Core Concept

In Dynamics 365 Finance, you never modify base objects directly. Instead, you use the event subscription model - copying event handler stubs and placing them in your own extension classes. The sequence reflects this pattern.


Why This Sequence

Step 1: Copy the validatedWrite event handler on the CustTable object

validatedWrite is the correct event because:

  • It fires when a record is about to be saved to the database
  • It returns a boolean - returning false blocks the save and displays an error to the user
  • It is the standard D365F validation hook for table-level record validation

In the AOT, you right-click the validatedWrite method on CustTable and select "Copy event handler method" - this gives you a correctly-typed delegate stub you can subscribe to without touching the base object.

Why not the distractors:

  • onWriting - fires during the write operation but is not designed to block saves with user-facing validation errors; it has no return value for validation
  • onModified - fires when a field value changes in a form, not on save; this would fire on every keystroke, not at record commit

Step 2: Add the event handler method to a class

You paste the copied stub into a new X++ class (e.g., CustTableEventHandler). This class is your extension artifact - it owns the handler method and is where D365F's event subscription wiring points. You cannot register a free-floating function; it must live in a class.


Step 3: Add code to perform the validation

Only after the infrastructure exists (correct event, correct class) do you write the logic - checking strlen(custTable.VINField) >= 10, and calling checkFailed("VIN must be at least 10 characters") if it fails.


Common Mistakes

MistakeWhy It's Wrong
Choosing onWriting for validationNo return value; can't block the save
Choosing onModifiedFires on field change, not record save
Writing code before adding to a classThe handler method has no home; it can't be registered
Modifying CustTable directlyViolates D365F's extension model; breaks on upgrades

Summary

The sequence is event selection → infrastructure → logic - a pattern you'll repeat for any D365F event handler: pick the right hook, place it in an extension class, then implement the business rule.

Topics

#event handler#validatedWrite#CustTable#data validation

Community Discussion

No community discussion yet for this question.

Full MB-500 Practice