• Deepak Patil 16
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi everyone,

Here is my business requirement:

On the standard Quote object, I have a custom checkbox field called PO_Attached__c. If a File is uploaded to a Quote record, PO_Attached__c should be updated to true. I currently achieve this functionality using the Attachments functionality by use of an Apex trigger.

However, we are now migrating to Files. I have updated my code block as below. It saves fine, but the checkbox is never updated. Any ideas why? Thanks in advance.
 
trigger quoteAttachment2 on ContentDocumentLink (after insert) {

                        List<Quote> listOfQuote = [select id from Quote where id =: Trigger.New[0].LinkedEntityId];
                        if(listOfQuote.size()>0)
                        {
                                    listOfQuote[0].PO_Attached__c = true;
                                    update listOfQuote;
                        }                                                                   
            }