• Marek Demiš 10
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
New to Apex coding so I am hoping that the community can help me. I am trying to create a trigger from Files that will check a custom checkbox field on the Opportunity when two Executed documents are uploaded to the related "Files" list. Here is what I have so far: 

trigger ContentDocumentLinkTrigger on ContentDocumentLink (before insert, before delete)
{
if(trigger.isinsert){
List<Opportunity> co = [select id from Opportunity where id =: Trigger.New[0].Id];
If(co.size()>0)        
{            
co[0].Executed_Docs_Attached__c = True;            
update co;        
}
}


if(trigger.isdelete){

List<Opportunity> co = [select id from Opportunity where id =: Trigger.old[0].Id];        
If(co.size()>0)        
{            
co[0].Executed_Docs_Attached__c = false;            
update co;        
}
}
}
However, this code is not updating the checkbox and I am not sure how or if I can specify to only update the checkbox if the file name has "Executed" included. Any thoughts would helpful. 
Thanks