Wednesday, 25 June 2014

Transaction Log - AX 2012 - Cannot create a record in Audit trail (TransactionLog)


I started getting this error after loading COM data on fresh AX2012 R3 environment. I found following post that pointed to the cause of this issue.  Following query lets you analyse the problem in SQL server management studio. For me reloading the COM data fixed the problem but if nothing works maybe updating SYSTEMSEQUENCES.NEXTVAL manually could solve it too.

Declare @NEXTVAL real

select @NEXTVAL = NEXTVAL from SYSTEMSEQUENCES where id = -2

--Following query will return rows if you are getting 'already exists' error
select * from TRANSACTIONLOG where CREATEDTRANSACTIONID > @NEXTVAL order by CREATEDTRANSACTIONID asc

Go

1 comment:

  1. Hi

    I have resolved the same issue in AX 2012,
    To over come this issue, please find the below code modifications in Tables-->TransactionLog-->Methods-->create.
    The existing Code:

    if (appl.lastTransactionIdCreated() != appl.curTransactionId())
    {
    transactionLog.Type = _type;
    transactionLog.Txt = _txt;

    transactionLog.insert();

    appl.lastTransactionIdCreated(transactionLog.CreatedTransactionId);

    appl.transactionlogUpdateTTSControl().revoke();
    }



    The changes to make:

    if (appl.lastTransactionIdCreated() != appl.curTransactionId())
    {
    if (!TransactionLog::find(appl.curTransactionId()))
    {
    transactionLog.Type = _type;
    transactionLog.Txt = _txt;

    transactionLog.insert();

    appl.lastTransactionIdCreated(transactionLog.CreatedTransactionId);
    }
    appl.transactionlogUpdateTTSControl().revoke();
    }

    Regards
    Pavan

    ReplyDelete