I wrote an integration app that imports contacts from an external system.
If the contacts already exists (ie. same name, or same email, or user selected) the data of the contact in salesforce is overwritten with the data of the contact in the ext system.
Therefore I would like to be sure that Field history tracking is enabled on those fields (Contact.FirstName,LastName,Email) and if not, enable it.
I saw here Field History : how to detect in apex which fields are tracked? that I can check wether the field is tracked or not, but as we could suppose :
Field is not writeable: FieldDefinition.IsFieldHistoryTracked
Is there any way to enable it programmatically ?
I saw that the Contact.object file changed when I manually activated the history on email field from
<enableHistory>false</enableHistory> ... <fields> <fullName>Email</fullName> <trackFeedHistory>false</trackFeedHistory> </fields>
<enableHistory>true</enableHistory> ... <fields> <fullName>Email</fullName> <trackFeedHistory>false</trackFeedHistory> <trackHistory>true</trackHistory> </fields>
So I guess deploying this file might be a way (even if I don't really know how), but how to do that in a package installation ?