As you already know Salesforce allows us to track history fields. Tracking history is useful especially if your business is within the regulatory sector and have auditors who want to view any changes that were made to a record. However, this functionality has some limitations. These are:
- We can track only up to 20 fields (not more).
- We can track changes up to 18 months.
The below solution is ideal if you require to track more than 20 fields and hold the data to as long as you need. In the scenario below I am assuming that the requirement is to track 4 different data types of fields (Text, pick-list, lookup and a checkbox). Follow my steps below.
Step 1: First step is to create a custom object and some fields (screenshot below). We will name the custom object “History” and the fields will be the following:
- Changed By
- Field (make sure it has a 255 character length)
- Old Value
- New Value
- Opportunity (this will be a lookup to the opportunity object)
*Once you do that update your Opportunity page layout and add History as a related list.
Step 2: Create a formula field in the opportunity object and name it Full Name (we will use this field in the flow – Lookup/Opportunity Owner) – Formula is “Owner.FirstName & ” ” & Owner.LastName” and will return text (you may want to hide it from the page layout if you want to)
Step 3: Create the Flow (Record-Triggered Flow)
- Create a Start Element
- Create a Decision Element
- Create a Single Record Variable (we will add this to the next Element which will be an Assignment element)
- Create an Assignment Element
- Create a Record Collection Variable (we will add this to the next Assignment Element)
- Create the second Assignment Element
- Create the “Create” Element
Repeat the above steps (the Decision and the 2 Assignment elements) for each of the fields you want to create. Video of the flow below. Once you finish Save and Activate your flow.
Video demo of the functionality below: