Search code examples
formsdialogaxaptax++dynamics-ax-2012

How to insert a record from a Form with Dialog confirm?


I insert with a Form records in MyTableNewRecord.

In my insert Table method iI insered this code:

dialog     dialog;
DialogText dialogText ;
DialogButton dialogButton;
DialogField dialogField;

dialog = new Dialog("Dialog user");
dialogText =
dialog.addText("Text dialog.");
dialogText = dialog.addText("Click OK to continue");

dialog.run();
super();

For to insert, I use a Form. In MyForm I used a SysListPanelRelationTableCallback for to insert data. This SysListPanel I created looklike:

sysListPanel = SysListPanelRelationTableCallback::newForm(element,
                     element.controlId(formControlStr(SysUserGroupInfo, Users)),
                     "@SYS25440", "@SYS57282", #ImageUser,
                     tablenum(MyTableRecord),
                     fieldnum(MyTableNewRecord, UserId),
                     fieldnum(MyTableNewRecord, AdministratorUse),
                     tablenum(TableFromRecords),
                     fieldnum(TableFromRecords, Id),
                     [fieldnum(TableFromRecords, Id),
                     fieldnum(TableFromRecords, Name)]
                     , 0, '' ,
                     "","");

When I put the User from right site to lest site(and add in MyTableNewRecords ), the DialogBox run, but, when I clicked OK(dialogBox DefaultButton), I give an error, looklike:

"Few or too ttsbegin/ttscommit . Current level TTS is 1"

I can insert a records if I only clicked on Escape (X).

How I can insert records after DialogBox?

I tried to insert ttsbegin; ttscommti; maybe I'm wrong to put them, because it gives me the same error.

I have to use another override method, but I tried with validateWritre and not even open the Dialog (test in Debug and does not pass through the method).

Or, It's possible to insert a confirm befor to add a record with ListPanel? I nedd to have a confirm and , after I have to add a record in a Table (MyTableNewRecord).

Thanks for yours time,

enjoy!


Solution

  • you should not write code that allows user interaction(ie a dialog) during a transaction

    https://msdn.microsoft.com/en-us/library/aa609617.aspx