1

Our app contains a workflow rule that sends an email to the user when a case or lead is assigned to them. The email template contains a component with a controller that uses soql to populate the email fields.

Does anyone know if populating and sending these emails via the workflow rule would count towards our governor limits? E.g. CPU time, SOQL queries etc.

1

According to the docs, at https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_gov_limits.htm :

CPU time is calculated for all executions on the Salesforce application servers occurring in one Apex transaction—for the executing Apex code, and any processes that are called from this code, such as package code and workflows. CPU time is private for a transaction and is isolated from other transactions. Operations that don’t consume application server CPU time aren’t counted toward CPU time. For example, the portion of execution time spent in the database for DML, SOQL, and SOSL isn’t counted, nor is waiting time for Apex callouts.

In your case, the workflow rule would count against CPU time if it was triggered from Apex code (so if you carried out the lead/case assignment via Apex code). If not, then only the time spent in the custom controller itself would count against the CPU time limit. If you want to know more about this limit, check out Josh Kaplan's blog post on the subject.

The SOQL queries will always count, as they are based on all of queries executed in a single transaction, regardless of where they are executed from.

| improve this answer | |
  • I ran the assignment with the workflow rule both on and off, and checked the limits in the debug logs. The CPU time was higher with the workflow rule on, as you said. However, there was no difference in the SOQL counts, either for the user or for our app namespace. – Jess Jul 21 '14 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.