web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

"An unbalanced X++ TTSBEGIN/TTSCOMMIT pair has been detected" Error

(0) ShareShare
ReportReport
Posted on by 225

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.

pastedimage1612963515880v1.png

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.

pastedimage1612963793062v2.png

I have the same question (0)
  • Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: "An unbalanced X++ TTSBEGIN/TTSCOMMIT pair has been detected" Error

    Hi Pratik,

    The TTS level makes sense as as there are ttsbegin-ttscommit blocks in the data source write method in both these forms.

    pastedimage1612972399669v1.png

    Instead on the onWritten event handler, can you try doing a CoC on the write method and check?

  • Pratik Rami Profile Picture
    225 on at
    RE: "An unbalanced X++ TTSBEGIN/TTSCOMMIT pair has been detected" Error

    Gunjan,

    Same happens in CustTable ( for customer record) Onwritten event handler too.

    In Vendtable, VendInvoiceInfoTable this thing is working fine. no issue there.

    If possible can you write my sample code(screeenshot above) in your environment and check what TTS Level you get when flow comes in event handler

  • Pratik Rami Profile Picture
    225 on at
    RE: "An unbalanced X++ TTSBEGIN/TTSCOMMIT pair has been detected" Error

    Ergun Sahin,

    till tts Level will be 1 in this block (OnWritten event handler method), I will get that error in dialog. so I want to know why it is  1 ?

    and why it is 0 when you click on save after editing any field value. what is the connection with changing field value and saving record ? in both the case tts should work same I think.

  • Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: "An unbalanced X++ TTSBEGIN/TTSCOMMIT pair has been detected" Error

    Hi Pratik,

    Is there any other event handler/ CoC method that could be causing the issue?

  • ergun sahin Profile Picture
    8,822 Moderator on at
    RE: "An unbalanced X++ TTSBEGIN/TTSCOMMIT pair has been detected" Error

    Dont pay attention to the tts level. The important thing is whether to get an error or not

  • Pratik Rami Profile Picture
    225 on at
    RE: "An unbalanced X++ TTSBEGIN/TTSCOMMIT pair has been detected" Error

    hi Ergun Sahin,

    As I have already mentioned I have removed dialog code. still on the first line of onWritten event handler I am getting TTS Level =1. which I think should be 0.

    My point is all TTS should be completed before flow comes in OnWritten event handler.

    After removing my class how I will be able to test ? At least I need that Info statement to test this case.

  • Pratik Rami Profile Picture
    225 on at
    RE: "An unbalanced X++ TTSBEGIN/TTSCOMMIT pair has been detected" Error

    Hi Gunjan,

    I am using VHD for Development. After restarting still getting issue

  • Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: "An unbalanced X++ TTSBEGIN/TTSCOMMIT pair has been detected" Error

    Hi Pratik,

    Is this on your Dev environment? Can you try restarting the AOS service to check if the issue persists?

  • ergun sahin Profile Picture
    8,822 Moderator on at
    RE: "An unbalanced X++ TTSBEGIN/TTSCOMMIT pair has been detected" Error

    Do you keep getting errors even though there is no dialogue?

    Did you make a full build?

    Do you keep getting errors when you remove your class completely and try?

  • Pratik Rami Profile Picture
    225 on at
    RE: "An unbalanced X++ TTSBEGIN/TTSCOMMIT pair has been detected" Error

    Hello Ergun Sahin,

    I have removed that dialog code as you can see in my code sample screenshot above. On the very first line of OnWritten event you will get TTS Level = 1, if you have clicked on save without changing any field value. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,339

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 824 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 600 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans