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
ringnengringneng 

Adding a custom field to EmailMessage SObject

Hi guys, I'm working with the API (PHP toolkit!), and on my page I'd like a list of emails that some users receive from Salesforce users.

 

To do this, I intended to create a IsRead__c custom field on my EmailMessage object, and take it from there. I don't see anywhere where that object could be modified. Does anyone know where I need to look or a better way to achieve this? Thanks!

Best Answer chosen by Admin (Salesforce Developers) 
apaiapai

Hey ringneng,

 

It is not possible to create custom fields for EmailMessage object. A workaround could be implemented based on the need to have this custom field.

 

Thanks.

 

 

All Answers

apaiapai

Hey ringneng,

 

It is not possible to create custom fields for EmailMessage object. A workaround could be implemented based on the need to have this custom field.

 

Thanks.

 

 

This was selected as the best answer
ringnengringneng

You're right. If it'll help anyone, I created a custom object and created a trigger that would copy the same information from EmailMessage right after the email was sent. Very simple. this is the trigger.

 

trigger Avantbox_Create_CP_Email on EmailMessage (after insert) {
Customer_Portal_Email__c CP_Email = new Customer_Portal_Email__c();

trigger Avantbox_Create_CP_Email on EmailMessage (after insert) {
    Customer_Portal_Email__c CP_Email = new Customer_Portal_Email__c();
    
    for(EmailMessage newCase: Trigger.new) {
        CP_Email.EmailID__c = newCase.Id;
        CP_Email.Subject__c = newCase.Subject;
        CP_Email.Status__c = 'Unread';
        CP_Email.Date__c = newCase.CreatedDate;  
        CP_Email.ParentId__c = newCase.ParentId;
          
        insert CP_Email;
    }
}
sunil g21sunil g21
This is no longer the case.