I want to create an auditing plugin that whenever a "contact" entity is changed, a "historical contact" entity is created that had all the data of the old "contact" entity before the change.
My question is, if I have a lookup field in "contact" to "accounts", how do I get this lookup to the specific "account" and place it in the lookup field for the "historical contact" entity?
I completed the plugin, but now there is a new issue.
The "contact" entity can have a blank in the "first name" field.
The "historical contact" entity has "first name" as its primary field, although it is not required.
If there is no "first name" when creating "historical contact" entity it throws an error. I do not know why this is.
Do I need a primary field to create an entity even if the field is labeled to have "no constraint"?