Log errors - AX - Save error messages to log table

 There are time when you want to save your log texts to a table in the middle of a situations when errors are being thrown  (in order to debug the problem) and code execution stops abruptly.
 If you have played with this, you will know that 'just saving' the text to a table and doing an insert won't just do ... because the record will never get committed.
 So, what you can do is just create another db connection scope and work in that one; the code is something like:

    UserConnection    connection;
    LogTable               log;
    connection = new UserConnection();    log.setConnection(connection);    connection.ttsbegin();

    log.Exception = _exception;

No comments:

Post a Comment