General X++ Development

How do I prevent partial database updates when an error occurs?

Asked by Sunny Vasty· Aug 13, 2026· 1 answers

How do I prevent partial database updates when an error occurs?

SSunny Vasty75 reputation · answered Aug 13, 2026

Put related writes inside the same transaction.

X++
ttsBegin;

header.update();
line1.update();
line2.update();

ttsCommit;

If one of those operations throws and the exception escapes the transaction, the transaction is rolled back instead of leaving half the operation committed.

That is exactly what ttsBegin/ttsCommit is for.