General X++ Development

How do I retry a transaction after an UpdateConflict exception?

Asked by Sunny Vasty· Aug 13, 2026· 1 answers

How do I retry a transaction after an UpdateConflict exception?

SSunny Vasty75 reputation · answered Aug 13, 2026

Use retry, but put a limit on it.

A common D365FO pattern uses the OCC retry macros:

X++
#OCCRetryCount

try
{
    ttsBegin;

    // Select for update and update logic.

    ttsCommit;
}
catch (Exception::UpdateConflict)
{
    if (appl.ttsLevel() == 0)
    {
        if (xSession::currentRetryCount() >= #RetryNum)
        {
            throw Exception::UpdateConflictNotRecovered;
        }

        retry;
    }

    throw;
}

Do not create an unlimited retry loop. If the same conflict keeps happening, eventually let the error surface so you can fix the actual problem.