How to catch system exception of duplicate records found and show own message

static void CatchException(Args _args)
{
    CustTable custTable;
    SysInfoLogLevel prevLevel = infolog.infologLevel();
    try
    {
        infolog.setInfoLogLevel(SysInfoLogLevel::None);
        custTable.AccountNum = “1”;
        custTable.insert();
        infolog.setInfoLogLevel(prevLevel);
    }
    catch(Exception::DuplicateKeyException)
    {
        infolog.setInfoLogLevel(prevLevel);
        info(“DuplicateKeyException”);
    }
}

Follow

Get every new post delivered to your Inbox.

Join 144 other followers

%d bloggers like this: