简体   繁体   English

System.QueryException:记录当前不可用

[英]System.QueryException: Record Currently Unavailable

This exception usually happens when a batch is being run or alerts are coming into our Salesforce instance too quickly. 当批处理正在运行或警报进入我们的Salesforce实例的速度过快时,通常会发生此异常。 When inserting a case, we try to lock down the contact and account associated with the case before inserting the case to prevent the 'UNABLE_TO_LOCK_ROW' exception from happening. 插入案例时,我们尝试在插入案例之前锁定与案例关联的联系人和客户,以防止发生“ UNABLE_TO_LOCK_ROW”异常。

Here is the exact exception: 这是确切的例外:

'System.QueryException: Record Currently Unavailable: The record you are attempting to edit, or one of its related records, is currently being modified by another user. 'System.QueryException:当前不可用的记录:您正在尝试编辑的记录或其相关记录之一,正在由另一个用户修改。 Please try again.' 请再试一次。'

Class.Utility.DoCaseInsertion: line 98, column 1 Class.Utility.DoCaseInsertion:第98行,第1列

I've done a lot of research on the 'UNABLE_TO_LOCK_ROW' exception and 'Record Currently Unavailable' exception and I can't seem to find a great solution to this issue. 我对“ UNABLE_TO_LOCK_ROW”异常和“当前记录不可用”异常做了很多研究,但似乎找不到解决此问题的好方法。

What I've tried to accomplish is a loop to attempt the insert 10 times, but I'm still getting the 'Record Currently Unavailable' exception. 我试图完成的操作是尝试插入10次的循环,但是我仍然遇到“当前记录不可用”异常。 Does anyone else have a suggestion for this? 有人对此有建议吗?

Below is the code: 下面是代码:

Public static void DoCaseInsertion(case myCase) {
    try
    {
        insert myCase;
    }
    catch (System.DmlException ex)
    {
        boolean repeat = true;
        integer cnt = 0;
        while (repeat && cnt < 10) 
        {   
            try
            {
                repeat = false;
                List<Contact> contactList = [select id from Contact where id =: myCase.ContactId for update]; // Added for related contact to overcome the 'UNABLE_TO_LOCK_ROW issues'
                List<Account> accountList = [select id from Account where id =: myCase.AccountId for update]; // Added for related account to overcome the 'UNABLE_TO_LOCK_ROW issues'
                insert myCase;
            }
            catch (System.DmlException e)
            {
                repeat = true;
                cnt++;
            }
        }
    }
}

This basically happens when there is a conflicting modification being done by other user/process on a particular record that you are trying to access. 当其他用户/进程对您要访问的特定记录进行冲突的修改时,基本上会发生这种情况。 Mostly it will happen when anykind of batch process is running in the background and locked the particular record you are trying to access(in your case Account). 通常,它将在后台运行任何类型的批处理并锁定您尝试访问的特定记录(在您的帐户中)时发生。 To get rid of this problem, you would need to check if there are any scheduled apex classes running in the background on Accounts/Cases and see if there is anything you can do to optimize the code to avoid conflicting behavior. 要解决此问题,您需要检查“帐户/案例”后台是否有任何预定的顶点类在运行,并查看是否可以做一些优化代码以避免行为冲突的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 失败消息:“ System.QueryException:实体&#39;Lead&#39;上没有这样的列&#39;Address&#39;。I - Failure Message: "System.QueryException: No such column 'Address' on entity 'Lead'. I System.QueryException:列表有超过 1 行分配给 SObject - System.QueryException: List has more than 1 row for assignment to SObject Salesforce控制器扩展测试:System.QueryException:列表中没有可分配给SObject的行 - Salesforce Controller Extension Testing: System.QueryException: List has no rows for assignment to SObject System.Exception:太多记录类型描述:101 - System.Exception: Too many record type describes: 101 当前设置的PHP curl标题 - php curl header set currently FMDatabase当前正在并发执行 - FMDatabase is currently in use on concurrent execution 503服务在Salesforce中不可用 - 503service unavailable in Salesforce Lightning Web 组件:recordId 在构造函数内部不可用 - Lightning Web Component: recordId unavailable from inside constructor 问&gt;访问visualforce页面时如何解决“当前不允许DML” - Q>How to fix “DML currently not allowed” when accessing visualforce page 为什么Azure给我一个间歇性的错误503.该服务不可用? - Why does Azure give me an intermittent Error 503. The service is unavailable?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM