Posts

Showing posts with the label APEX

🛠️ Custom Field Change Tracking in Salesforce – Overcoming Limitations of Field History Tracking

Salesforce is powerful, but like every platform, it has limitations. One such limitation is related to Field History Tracking —you can only track up to 20 fields per object , and even then, certain field types (like long text areas) aren’t supported. I recently came across this limitation during a project where tracking every update to Task fields was critical for compliance and reporting. So, I designed a custom field tracking solution using Apex Triggers and a custom object. In this post, I’ll walk you through how I built it and how you can implement it too. ❗ Why Custom Tracking? Out-of-the-box Salesforce lets you: Track up to 20 fields per object. Track changes on limited data types (excludes Long Text Area, Rich Text, etc.) View changes only in the standard history related list. But in my case, I needed to: Track more than 20 fields. Track long text fields like Description . Store change history in a separate custom object. Restrict deletion of histor...

Order of execution in Salesforce

Image
  Here is Order of execution. Salesforce performs the following events in below order.      Loads Initial record.      If the request came from a standard UI edit page, Salesforce runs system validation to check the record for page layout specific rules, field definition, Maximum field length.      Executes flows that make before-save update. (New Change in Winter 20)      Executes all before triggers.      Runs most Custom validation.      Executes duplicate rules.      Saves the record to the database, but doesn’t commit yet.      Executes all after triggers.      Assignment rules.      Executes auto-response rules.      Executes workflow rules.      If there are workflow field updates, updates the record again.      Due to Workflow field updates introduced new duplicate field val...