Good evening
Michal Kupczyk from this thread on the Microsoft communities proposes a much better way to log independantly of transaction scope in Dynamics Ax than what I had originally proposed here. Instead of using a separate thread to log, is uses a UserConnection object.
In addition to being simpler, it also has the added value of working from within batches. Batches it seems don’t support multithreading.
void method()
{
UserConnection conn = new UserConnection();
{
UserConnection conn = new UserConnection();
yourLogTable = null;
yourLogTable.setConnection(conn);
ttsbegin;
[…]
yourLogTable.Log = ‘This is tts-independent log’;
yourLogTable.insert();
yourLogTable.insert();
if (some_error)
{
throw Error(‘Error in processing’);
}
ttscommit;
}