function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

trigger Error

Any ideas? Its driving me mad!

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.
its a custom object field. What should precede 'DRM_Contact_Employer__c'? 
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?
yes thats correct. I think it should be custom object plus custom object field : Employment_History__c.DRM_Contact_Employer__c =;
Yeah your code should probably be something like:
trigger PrimaryAccount on Contact(before insert, before update){
  List<Employment_History__c> histories = new List<Employment_History__c>();
  for(Contact con:{
    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
  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.