+ Start a Discussion
Prateek Kapur 6Prateek Kapur 6 

We have created an apex class which generate pdf once the order has been created and the pdf get automatically get attached to the Opportunity's Notes & Attachments. It is working fine but it didn't executed one time in between, what cud be the reason?

Nitesh K.Nitesh K.
Hi Prateek First You have to check 

For Ex
Opportunity opp;
Boolean flag=false;
Try{
opp=[SELECT Id,(Select id from Attachments) From Opportunity];
if(opp.Attachments.Size()>0){
for(Attachment att:opp.Attachments){
if(att.Name=='AttName') //AttachmentName Given Name check
flag=true

}
else if(flag==false){
//Create Pdf Logic and attach here
}
}
}Catch(Exception e){

}

Let me know if this helps.
Prateek Kapur 6Prateek Kapur 6
Hi Nitesh,

Thanks for the reply, I had incorporated this code in the apex class, issue is its working for all the opportunities but it didn't work in case of one of the opportunity order and i am looking for the possible reason for such exception to occur. 
Nitesh K.Nitesh K.
what exception is coming paste