MB-500 · Question #267
A company uses Dynamics 365 Finance. You implement the Insert method for a table you create. The class must meet the following requirements: - If FieldA is equal to "Hello," then FieldB must save…
The correct answer is A. public void insert() { switch (this.FieldA) { case "Hello": this.FieldB = 10; break; case "World": this.FieldB = 20; break; default: this.FieldB = 0; break; } super(); } C. public void insert() { if (this.FieldA == "Hello") { this.FieldB = 10; } else if (this.FieldA == "World") { this.FieldB = 20; } else { this.FieldB = 0; } super(); }. Options A and C are correct because they both set the field values before calling super(), which is the critical requirement in X++ table methods - super() triggers the actual database insert, so all field assignments must occur first. Both a switch statement (A) and an if/else…
Question
Exhibits
Options
- Apublic void insert() { switch (this.FieldA) { case "Hello": this.FieldB = 10; break; case "World": this.FieldB = 20; break; default: this.FieldB = 0; break; } super(); }
- Bpublic void insert() { if (this.FieldA == "Hello") { this.FieldB = 10; } else if (this.FieldA == "World") { this.FieldB = 20; } else { this.FieldB = 0; } super(); }
- Cpublic void insert() { if (this.FieldA == "Hello") { this.FieldB = 10; } else if (this.FieldA == "World") { this.FieldB = 20; } else { this.FieldB = 0; } super(); }
- Dpublic void insert() { switch (this.FieldA) { case "Hello": this.FieldB = 10; break; case "World": this.FieldB = 20; break; default: this.FieldB = 0; break; } super(); }
How the community answered
(24 responses)- A75% (18)
- B17% (4)
- D8% (2)
Explanation
Options A and C are correct because they both set the field values before calling super(), which is the critical requirement in X++ table methods - super() triggers the actual database insert, so all field assignments must occur first. Both a switch statement (A) and an if/else if/else chain (C) are valid X++ constructs for this conditional logic, giving two equally correct solutions.
Options B and D are wrong because, in the actual exam images, they call super() before the conditional logic - meaning the record is written to the database before FieldB is assigned, so the 10/20/0 values are never persisted correctly.
Memory tip: Think of super() in an insert() override as the "commit" button - always set your values first, then commit. A helpful phrase: "Prepare, then persist" - field logic comes before super().
Topics
Community Discussion
No community discussion yet for this question.



