Tracking history for account team object in salesforce

I want to track the changes done to my account team object similar to account hsitory . Can any one suggest the best method possible to achieve this?

Answer

You could create a custom object to hold these data changes. Then create a trigger on the AccountTeamMember object and insert the changes into your custom object.

So for instance on your custom object lets call it AccountTeamHistory__c, you have the following fields

Date - Date of the transaction
Action - The DML action that occurred, Insert, Update, Delete, etc. 
Member - The contact that was added updated, deleted, etc. 
Before_Role - The role before the action    
After_Role - The role after the action

In your trigger you simply create a new instance of this custom object and populate the fields with the values from the trigger context variables and insert the new object.

Attribution
Source : Link , Question Author : user4218 , Answer Author : Chris Duncombe

Leave a Comment