Configuration Best Practices
Jump to
Workflow Rules
Evaluation Criteria
When a workflow rule is enabled, the evaluation criteria for that rule is queried each time the corresponding entity is updated or created.
It’s important to ensure the evaluation criteria are set up based on the following rules and order to ensure optimal performance.
- Order of simplicity: the most simple expression comes first
- When using AND the least likely expression should be first
- When using OR the most likely expression should be first
- Use IsChanged() in “Every time a record is created or edited”
- Use catch() instead of IsNull() on nested references
Rule #1 – Order of simplicity: the most simple expression comes first
Rule #2 – When using AND operators the least likely expression should be first
Rule #3 – When using OR operators the most likely expression should be first
Rule #4: use IsChanged() for “Every time a record is created or edited”
*IsChanged() doesn’t return true if it's a new object (use IsNew() instead)
Rule #4.1: Reduce executions on user-related workflows by ignoring logins
Rule #5: leveraging Catch() instead of IsNull()
* For other types of validations, prefer If block over Catch()
Actions
Rule #1: Leverage variables to avoid multiple function calls
Rule #2: Do not use SysId as an object reference
Custom Fields
Formula-based Custom Fields
Formula fields will only be calculated when an object is changed, and only when the fields in the formula depend on change.
- In general, Formula fields and workflow rules run at the same speed
- Optimally, all database columns load prior to execution
- If an entity was modified concurrently (in a different transaction), a job is triggered
- Formula evaluation criteria needs to be as simple as possible based on the evaluation criteria rules
Rollup Fields
Rollup fields are slower than formula fields or workflow rules but they are calculated inside the project calculation process (i.e. in memory), so their overhead is still small. If you have many of those then you will slow down any update to the project.
- It’s very hard/impossible to implement rollup via workflow rules so you don’t have much choice here
- The Formula and Rollup criteria need to be as simple as possible based on the evaluation criteria rules
Relation summary fields
- Relation Summary fields are the slowest type of custom field
- Runs as a groupable job (outside of the Save transaction)
- Workflow rule may be more efficient in some cases
For example, if you are implementing Count by referencing additions and deletions of links and just incrementing or decrementing the counter