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
J80J80 

trigger expression error

Any Idea what is going wrong here?

Error
Dushyant SonwarDushyant Sonwar
Hey Buddy,
you cannot get related list in trigger.new
See this
http://salesforce.stackexchange.com/questions/46289/trigger-not-getting-parent-object-field-values
fundooMentalfundooMental

You have pasted the image and it is so tiny, had to zoom to see the code :P

 You are directly accessing the field of Employment_History__c object without getting the record. You need to either get the record of Employment_History__c through SOQL or create a new record for Employment_History__c and then assign the value con.Account.Name to it.

Himanshu ParasharHimanshu Parashar
Hi,

You need to first create object of that Employment_History__c such as
 
Employment_History__c  EH = new Employment_History__c ();
EH.DRM_Contact_Employer__c = con.Account.name.

and as Dushyant said already you can't get Account.Name here directly so for that you can create a formaula field on contact and use that for assignment.

Thanks,
Himanshu
Salesforce Certified Developer | Administrator | Service Cloud Consultant

P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.