Skip to main content

trigger UpdateAttachmentID on Contact (after update) {

List<Attachment> aid=new List<Attachment>();

Set<Id> conid=new Set<Id>();

List<Contact> conatt=new List<Contact>();

for(Contact con1:Trigger.new)

{

conid.add(con1.Id);

}

conatt=[select Description from Contact where ID IN:conid];

String qry='[select id from Attachment where ParentId IN:conid.getID()]';

for(Contact con2:conatt)

{

con2.Description=qry;

conatt.add(con2);

}

update conatt;

}

 

 
16 answers
  1. Jun 29, 2018, 6:04 AM
    @ Prashant

     

    Now that's what I am talking about! :D

     

    *In case of multiple attachments, we can do someting like this:

     

    c.Description=c.Description+'\n'+atc.Description;