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
GauravKumarGauravKumar 

Execute trigger on Email Message and Update Attachment ParentId

Can anybody help me how can i do this

When an email  record is created and linked to a Case, then attachment files linked to the email record moved to be part of the Attachments related list for the Case, not the Email.

 

My trigger code is

 

 

trigger emailAttachment on EmailMessage (after insert) {
 
 Attachment[] atts = new Attachment[] {};
 for (Attachment a : [Select ID, ParentID From Attachment Where ParentID IN: trigger.new])
 {
  a.ParentId = trigger.newMap.get(a.ParentID).ParentID;
  atts.add(a);
 }
 if (!atts.isEmpty())
  update atts;
 
}

 

 

this is giviming me no rows.

how can i do this? can anybody help me plz ?

Thanks in Advance

GauravKumarGauravKumar

can anybody guide me how can i do this ?

 

Thanks in Advance

SFDC-vishnuSFDC-vishnu

Please if any response ,it would be helpfull