• BrianJ
  • NEWBIE
  • 10 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
I created a trigger that outputs error if checkbox is true and no document is attached. 

It's working great. However, I've read here that I should bulkify it so that I don't hit SOQL query limits. 

I need help bulkifying the below code. Thank you :)
trigger ReportRequestTrigger on Report_Request__c (before update, after update) {
    for(Report_Request__c rr:Trigger.New) {
        if(rr.Will_Receive_Provider_Facility_Claims__c== TRUE) {
            LIST<ContentDocumentLink> attachments = [SELECT ContentDocumentId, LinkedEntityId  FROM ContentDocumentLink where LinkedEntityId = : rr.Id];
            if(attachments.size()<=0){
                rr.adderror('You cant select "Will Receive Provider Facility Claims" without attaching a Zip Census');
            }
        }
    }
}

 
  • February 18, 2021
  • Like
  • 0
I created a trigger that outputs error if checkbox is true and no document is attached. 

It's working great. However, I've read here that I should bulkify it so that I don't hit SOQL query limits. 

I need help bulkifying the below code. Thank you :)
trigger ReportRequestTrigger on Report_Request__c (before update, after update) {
    for(Report_Request__c rr:Trigger.New) {
        if(rr.Will_Receive_Provider_Facility_Claims__c== TRUE) {
            LIST<ContentDocumentLink> attachments = [SELECT ContentDocumentId, LinkedEntityId  FROM ContentDocumentLink where LinkedEntityId = : rr.Id];
            if(attachments.size()<=0){
                rr.adderror('You cant select "Will Receive Provider Facility Claims" without attaching a Zip Census');
            }
        }
    }
}

 
  • February 18, 2021
  • Like
  • 0