It won't compile because your contact object does not have a field with that name on it. Check your Contact object and validate that the api name of the field is as you are expecting.
What are you trying to do? From your code it seems that when an Contact is inserted or updated you wish to set a field on the Contact to be the Name of the Account related to that Contact. Is that correct?
trigger PrimaryAccount on Contact(before insert, before update){
List<Employment_History__c> histories = new List<Employment_History__c>();
for(Contact con: trigger.new){
Employment_History__c newHist = new Employment_History__c();
newHist.DRM_Contact_Employer__c = con.Account.Name;
newHist.Contact__c = con.Id; //This will need changing to be a correct relationship
histories.add(newHist);
}
insert histories;
}
Note that you will probably want to relate your Employment HIstory object to the contact so that this makes sense (see the comment in the code). For the record, you could just create a formula field on the Employment History object to display the Account Name without the need for any code.
Note that you will probably want to relate your Employment HIstory object to the contact so that this makes sense (see the comment in the code). For the record, you could just create a formula field on the Employment History object to display the Account Name without the need for any code.