function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SrinuSrinu 

Email-to-case emails not creating cases

Hi,

 

Occasionally we seem to have a problem where emails received by Salesforce do not create cases. his causes us a serious issue as requests (orders) from customers will likely be missed. 

 

We receive a warning by email which states: 

"...The following errors were encountered while processing an incoming email: 

UNABLE_TO_LOCK_ROW : unable to obtain exclusive access to this record..."

 

 

What i did for this is:

We have 3 triggers on Case Object, which fires upon case creation for an incoming Email from customers. Put all the code in try catch blocks and write a chatter post in catch block. There by chatter group people will get a chatter post upon any lock error from any trigger. There by we can move that code to batch class and call it in future method. So that, we can remove that lock error.

 

Does my approach solve this problem?

 

Any suggestions would be appreciated?

 

 

Vinita_SFDCVinita_SFDC

Hello Srinu,

 

If a case is attempting to be created and another user in your organization is also working on a parent record then a lock could be placed within the database that will prevent updates to that record.  This is done to maintain data integrity.

For example, John, from ABC Inc., is attempting to log a case via Email-to-Case, but at the same time Dave (an employee within your organization) is making changes to the Account record for ABC Inc.  The ABC Inc. record is locked during this time and an error is generated referencing this lock and the case creation fails.  The case will need to be manually created at this point. For details please refer following link:

 

https://help.salesforce.com/apex/HTViewSolution?urlname=How-can-I-avoid-getting-lock-errors-in-my-organization-1327109108393&language=en_US

SrinuSrinu

Hi Vinita,

 

Thanks for your quick reply,

 

I knew the reason behind this error. I am looking into solution. How can I avoid this lock error and atleast create the cases manually for the missed cases.

 

My Approach:

Since no email Message has been saved (incoming email) in DB in case of any lock error, we can't get that ID. There by we can't create a case manually for that EmailMessage. 

So, what I did is, combined all the 3 case triggers into a single trigger with try catch block for each individual trigger. Catch block contains chatter post to Admin. Incase of any error in try block, chatter post will be delivered to Admin with case details and also with which trigger is causing error. After that, we can move that trigger to batch class and call it in future to solve the error.

 

Can you look into my approach and let me know, bu that can i solve this prob?

 

 

Ben CashenBen Cashen
Srinu,
Did you ever find a solution to this problem? We are having similar issues and attempting to do a similar solution where we "catch" the error and then manually create a case. 
Thank you.

Sandy CartographerSandy Cartographer
Hi Ben/Srinu, 
Did either of you find a solution? I am facing the same problem.