Hello,
There is a requirement that specifies that when the user changes a value in the X fields, he should specify the reason for the change.
The X field is a standard field in SalesTable. I wrote the following code that, after changing the value of the field, displays a dialog form for the user to select the reason for changing the X field. The selected reason is saved in an additional field in the table.
1 I extended the update() method in SalesTable
public void update()
{
SalesTable salesTable_orig = this.orig();
next update();
if(this.Field_X != SalesTable_orig.Field_X)
{
this.runDialogToChangeReason(this.SalesId);
}
}
2. The runDialogToChangeReason method, with _salesId as an argument
public void runDialogToChangeReason(SalesId _salesId)
{
Dialog dlg;
DialogField dfg;
dlg = new Dialog();
dfg = dlg.addField(EnumStr(ChangeReason), "Reason");
if(dlg.run())
{
salesTable::setChangeReason(_salesid, dfg.value());
}
}
3. The setChangeReason method, with _salesId and _reason as an arguments
public static void setChangeReason(SalesId _salesId, ChangeReason _reason)
{
SalesTable salesTable = SalesTable::find(_salesId);
ttsbegin;
salesTable.selectForUpdate(true);
salesTable.ReasonField = _reason;
salesTable.update();
ttscommit;
}
When selecting a value in the dialog and attempting to save, I always get the error "An unbalanced x TTSBEGIN/TTSCOMMIT pair..."
I tried debugging, but when starting the dialog, I immediately get the aforementioned error....
I also tried to insert ttsabort but also without success....
if (appl.ttsLevel() != 0)
{
ttsabort;
}
Could I have your help please?