nerdexam
Microsoft

MB-500 · Question #240

A company uses Dynamics 365 Finance. You must create a process that updates the following: - A single record for customer number A0001 in the customer table. - The value of its customer group to 10…

The correct answer is D. select forupdate custTable where custTable.AccountNum == 'A0001'; ttsbegin; custTable.CustGroup = '10'; custTable.update(); ttscommit. Option D is the only choice that includes all three required elements: forupdate (which locks the record and permits modification), a where clause targeting the specific customer (AccountNum == 'A0001'), and a properly wrapped transaction using ttsbegin/ttscommit around the…

Develop and test code

Question

A company uses Dynamics 365 Finance. You must create a process that updates the following: - A single record for customer number A0001 in the customer table. - The value of its customer group to 10. You need to implement the process. Which code segment should you use? A. B. C. D.

Exhibit

MB-500 question #240 exhibit

Options

  • Aselect forupdate custTable where custTable.AccountNum == 'A0001'; custTable.CustGroup = '10'; custTable.update();
  • Bselect forupdate custTable; ttsbegin; custTable.CustGroup = '10'; custTable.update(); ttscommit;
  • Cselect custTable where custTable.AccountNum == 'A0001'; custTable.CustGroup = '10'; custTable.update(); ttscommit;
  • Dselect forupdate custTable where custTable.AccountNum == 'A0001'; ttsbegin; custTable.CustGroup = '10'; custTable.update(); ttscommit;

How the community answered

(33 responses)
  • A
    3% (1)
  • B
    9% (3)
  • C
    3% (1)
  • D
    85% (28)

Explanation

Option D is the only choice that includes all three required elements: forupdate (which locks the record and permits modification), a where clause targeting the specific customer (AccountNum == 'A0001'), and a properly wrapped transaction using ttsbegin/ttscommit around the actual data change and update() call.

Option A fails because it omits ttsbegin/ttscommit - without a transaction block, the update() call will throw a runtime error in X++, since record updates require an explicit transaction.

Option B is wrong because it lacks the where clause on the select, meaning it targets an unfiltered (first) record rather than customer A0001 specifically.

Option C is missing the forupdate keyword on the select and is missing ttsbegin - without forupdate, the record is read-only and cannot be updated, and without ttsbegin, there is no open transaction to commit.

Memory tip: Think of the acronym FWT - ForUpdate (lock it), Where (find it), Transaction (commit it). Any answer missing one of those three is wrong.

Topics

#X++ SQL#forupdate#transaction management#record update

Community Discussion

No community discussion yet for this question.

Full MB-500 Practice