+ Start a Discussion
satyamsatyam 

Please help to correct the mass clone record with attachment trigger1

Hi,

 

I am mass cloning the record and for mass cloning the attachment i have written the trigger but its cloning the attachment of first record only and i want to mass clone the attachment with record also.

 

Can anyone please help me to resolve mu problem .Help will really appriciated.Please find attached my trigger below.What changes needed to do for mass cloning the attachment also.

 

trigger CopyAttachments on New_Support__c(after insert)
{
List<Id> parentIds=new List<Id>();
Attachment[] attList = [select id, name, body from Attachment where ParentId = :Trigger.new[0].Parent_New_Support__c];
Attachment[] insertAttList = new Attachment[]{};

for(Attachment a: attList)
{
Attachment att = new Attachment(name = a.name, body = a.body, parentid = Trigger.new[0].id);
insertAttList.add(att);
}
if(insertAttList.size() > 0)
{
insert insertAttList;
}

}

 

Thanks in advance:-)

bob_buzzardbob_buzzard

This is a cross post from the apex board.  Please don't do this.

satyamsatyam

K sure bob.

 

Can you please give me any idea to resolve my problem.

 

 

Thanks in advance for your help.