Wednesday, August 13, 2025

Try catch using x++ d365fo

#OCCRetryCount

try

{

    // Write base logic here

}

catch (Exception::Deadlock)

{

    if (xSession::currentRetryCount() >= #RetryNum)

    {

        throw Exception::Deadlock;

    }

    else

    {

        retry;

    }

}

catch (Exception::UpdateConflict)

{

    if (appl.ttsLevel() == 0)

    {

        if (xSession::currentRetryCount() >= #RetryNum)

        {

            throw Exception::UpdateConflictNotRecovered;

        }

        else

        {

            retry;

        }

    }

    else

    {

        throw Exception::UpdateConflict;

    }

}

catch

{

    error("");

}


Call API using x++ D365FO

 System.Net.HttpWebRequest    request; System.Net.HttpWebResponse   response; System.IO.Stream             dataStream; System.IO.StreamReade...