+ Start a Discussion

Notes And Attachments

Hi All,


If opportunity stage should to close user have to upload a doc for this i wrote a trigger its working good, now issue is if that attachment is deleted ,opportunity stage should be old value what i have to do how i can wrote trigger on notes and attachment help me

You can create trigger on Attachment with the help of Force.com IDE/Eclipse IDE.
trigger triggerName on Attachment (after delete) {
List<Opportunity> opps = [Select Id, Stage, Attachment from Opportunity where Id = : Trigger.New[0].ParentId];
if(opps.size() > 0){
for(Opportunity opp : opps){
opp.Stage = 'old value';
update opp;
hope this will help you.

Trigger[0]. id will not work  , need to be bulkified 


create a list of id & then query with that with In clause


@vijit Capgemini Developer