+ Start a Discussion
Cody Bustamante 9Cody Bustamante 9 

Cannot execute trigger: Apex CPU time limit exceeded.

I have a series of process builders that are routinely causing this error. I have already enabled: Query optimization in bulk mode. Is there a limit to the number of process builder that are recommended running at a single time or what can I do to help resolve this? 


Here is one of the error messages I get frequently: 

Cannot execute flow trigger: We can't save this record because the “Regional Territory Assignment” process failed. Give your Salesforce admin these details. This error occurred when the flow tried to update records: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: DSCORGPKG.DiscoverOrgCustomMapping_Lead: System.LimitException: Apex CPU time limit exceeded. You can look up ExceptionCode values in the SOAP API Developer Guide. Error ID: 93739643-76958 (-820305936)
Ryan GreeneRyan Greene
Usually the "Apex CPU time limit exceeded" error means there is some Apex code stuck in a loop. Do you have code named: "DSCORGPKG.DiscoverOrgCustomMapping_Lead" or just "DiscoverOrgCustomMapping_Lead"? Most likely your Process Builder is running and throwing the Apex into a loop. Might need to find that Apex then fix it or the Process based on your findings. If you need help reading the Apex code post it here and I'll take a look!
Good luck! 
Cody Bustamante 9Cody Bustamante 9
Hi Ryan, 

Thanks a ton for offering to help. To be honest I have no idea about any of this stuff. I started at my org about a year ago with no one to train me. I've gotten pretty good so far but there is still a ton of stuff I don't know about. We recently implemented a third party integration called DiscoverOrg but I'm not sure where I would find that code. And honestly, this isn't the only Process Builder error I'm getting. I'm getting a ton, but our SF subscription doesn't allow me dev support. I feel really overwhelmed with all of it. 

Where might I find that APEX code? 
Ryan GreeneRyan Greene

Hi Cody, No problem! I know its hard starting out, especially when you're figuring it out on your own.

Since DiscoverOrg is a third party integration you would not be able to modify their code. Could you post a screenshot of your Process Builder? Looking at that could help solve the error.
Thanks

Cody Bustamante 9Cody Bustamante 9
Thanks for listening haha! 

Sure, I'll post this one, then maybe after you help me review this one I can get my hands dirty on the other ones with this experience. There are 11 sets of criteria being evaluated. I'll just post an example, they are all pretty similar:

This process builder first evaluates if the industry is missing (a required field for our org once they get to a certain stage (MQL - Marketing Qualified) and then evaluates the next criteria

Then it looks at industry and routes the lead to either a "Channel" Governmentoverment" territory

Then finally it looks to states - if it doesn't match the above criteria then it looks to the state and assigns a regional territory:

User-added image
User-added image
User-added image
User-added image
User-added image
 
Cody Bustamante 9Cody Bustamante 9
User-added image
User-added imageUser-added image

There are 11 of these. I have another one I'm making that does this and changing lead status and lead owner all at the same time. That process builder has 25 criteria evaluation stages with as many as 45 logic filters in each. I'm wondering if these things are just too big. 
 
Ryan GreeneRyan Greene
These are not too big! I have many Proccess Builders set in several different objects and very large Processes built inside, so don't worry about them being too big!
One thing that helped a lot with my processes was to expand that Advanced arrow in the "Define Criteria for this Action Group" then check the box to only run the process when specified changes are made.
I do not see anything too crazy in your Process. If checking that box doesn't help you may need to contact support at DiscoverOrg. As you mentioned, you dont have access to SF Dev support, but this could be a DiscoverOrg issue, and they would be the ones to fix their code if needed. 
 
Cody Bustamante 9Cody Bustamante 9
Ok awesome, Thanks Ryan. Makes me feel better that it's not just too much for SF to handle. Have a great week.

Cody