+ Start a Discussion
Chermadurai BalaChermadurai Bala 

Unable to Use the fields LastModifiedDate and createdDate for Object "Email Message" in my Class

I Enabled audit fields , Even unable to Save my class when using LastModifiedDate and createdDate for Object "Email Message".

The Error Message is :
Error: Compile Error: Field is not writeable: EmailMessage.LastModifiedDate at line 159 column 38
Raj VakatiRaj Vakati
Hi Bala ,
LastModifiedDate and created date is read only fields and Salesforce will generate it automatically at the time of DML.

Thanks ,
Raj 
  
Chermadurai BalaChermadurai Bala
So, we can't use this field in our class for Creating new Records for Email Message.Right?
Alan SierraAlan Sierra
Hello, the fields on the sObject EmailMessage "Created Date" and "Last Modified Date" not will be modify. (https://developer.salesforce.com/docs/atlas.en-us.sfFieldRef.meta/sfFieldRef/salesforce_field_reference_EmailMessage.htm

Create new fields in the sObject and use it.