function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
r3rr3r 

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

Parth_SevakParth_Sevak
You can create trigger on Attachment with the help of Force.com IDE/Eclipse IDE.
Eg,
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.
avijchakavijchak

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