You need to sign in to do that
Don't have an account?

I want to show error on more than 4 attachments using trigger
I tried but my code is not working
Can someone help me on this
trigger AttachmentTrigger on Attachment (before insert) { Set<Id> attid = new Set<Id>(); for(Attachment att : Trigger.new){ attid.add(att.parentId); } Map<Id,Account> acMap = new Map<Id,Account>([select id,(select id,parentId from attachments) from Account where Id IN : attid]); for(Attachment att : Trigger.New){ if(acMap.get(att.parentId).attachments.size() > 4 ){ att.adderror('You can not add more than 4 attachments!'); } } }
Can someone help me on this
if(acMap.get(att.parentId).attachments.size() > 3 ){
Thanks let us know if it helps you
All Answers
if(acMap.get(att.parentId).attachments.size() > 3 ){
Thanks let us know if it helps you
Please check below code ,
Let me know if it helps !!!
Thanks
Manoj