Unbalanced X++ TTSBEGIN/TTSCOMMIT
This error usually leaves your Ax session in an unusable state that you can’t do nothing properly. It happens because of uneven ttsBegin and ttsCommit inside the code and most of the time, if not all, is caused by customizations.
The first step to solve this problem is to check all code for form or class from where this error comes (comparing layers might help), ttsBegin and ttsCommit must always be used in a clear and well-balanced manner. Balanced ttsBegin and ttsCommit statements are the following:
- Always in the same method.
- Always on the same level in the code.
Also, keep it in mind this tip by Martin Dráb:
“Never ever ask for user input inside database transactions. Collect all input before starting the transaction. If you find that you can’t continue without user input, abort the transaction (by throwing an error) and run it again when you have all information.”
A quick way to resolve this error is to set the TTS Level to zero. We can do it by using the command ttsAbort, but this will abort all the uncommitted transactions and data might be lost in the process and you still have to look for the unbalanced ttsBegin and ttsCommit statements
This job will check if the TTS level is greater than zero, if true it will reset TTS level by calling ttsAbort.
static void _ResetTTS(Args _args) { while (appl.ttsLevel() > 0) { info( strfmt("Level %1 aborted" ,appl.ttsLevel())); ttsAbort; } }
This was originally posted here.
*This post is locked for comments