Hello,
I am facing one issue on writing logic on save on Purchase Order.
I have used onWritten event of PurchTable & PurchLine datasource to perform logic on save. I want to display one dialog on save with Yes & No buttons. on Yes it will open one URL in new tab on No it will close that dialog.
I am getting "An unbalanced X++ TTSBEGIN/TTSCOMMIT pair has been detected" Error as shown in below screenshot on clicking Yes/No if I had clicked Save without changing any field value of Purchase Order.

If I change any field value and then click on Save then it is working properly.
I have not used any TTSBEGIN or TTSCOMMIT in my code. so there is no chance of missing TTSCOMMIT statement. I have also tried running job with ttsAbort; statement as suggested in many threads but still getting this error.
I am getting TTS Level = 1 if I click Save without changing any field value. and TTS Level = 0 if I click Save after changing any field value. below is my sample code. so issue start from first line no matter if I write logic to display dialog or not.
