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
Scott Wong 12Scott Wong 12 

APEX CPU TIME OUT B/C of Marketo Trigger

Hi There,


I have a Salesforce Process that automatically changes a Contact's Owner to match the Account Owner upon Account Owner Change. 

This process seems to be getting tripped up by a Marketo Trigger from the Marketo Sales Insights Managed Package, but I cannot see the code behind it to troubleshoot. Here is the error message I get: 

"UPDATE --- UPDATE FAILED --- ERRORS : (CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY) mkto_si.RemoveInterestingMomentLinebreaksContact: System.LimitException: Apex CPU time limit exceeded" 

I wrote to Marketo and they said this:

"The Apex CPU trigger is actually within Salesforce. As we do not have any access to drill down into Salesforce, we cannot fix it. Marketo isn't causing the Apex trigger, Marketo is trying to update a field within Salesforce and the Salesforce Apex CPU time out is happening before Marketo's update can process. This is why you are getting the update failed error. "

My gut says it's because the code within the trigger, but I can't see it because it's a managed package.

Anyone have any work around for this? I am just updating ~100 account records so I'm not sure why this would be timing out. 

Nishad KNishad K
Hi Scott,

To avoid CPU limit you need to optimize your code. Here are few tips:
1) Check the trigger execution and note the required time.
2) With the help of developer console you can figure out where cup time is spent and then target the area which most CUP costly.
3) try and optimize those costly code blocks
4) Note for optimization of trigger you can use anomalous block to fire trigger

Ref: https://developer.salesforce.com/page/Troubleshooting_Apex_Performance_Problems

Regards,
Shobit GuptaShobit Gupta
Few points here:
  • As it is a managed package, you cannot see/change the code of the trigger.
  • You have mentioned that there is a Salesforce Process that automatically changes a Contact's Owner to match the Account Owner upon Account Owner Change in your org. Are you using trigger for this process? If yes, then you need to change this trigger's code as this would be after trigger. Please check the link for Order of execution and optimize your code. https://help.salesforce.com/articleView?id=000005694&language=en_US&type=1
  • As Marketo team replied that the trigger is updating a field within salesforce and Salesforce Apex CPU time out is happening before Marketo's update can process. Please check if that field update is really happening or if you need to otimize it.