Questions tagged [bulkification]

The practice of structuring code to handle processing multiple records in one transaction. It should scale from processing a single record to hundreds (or more).

Filter by
Sorted by
Tagged with
2
votes
1answer
25 views

Scheduled Flow Bulkification

There is not much documentation yet surrounding the release of Scheduled Flows (Winter 20). This article (https://releasenotes.docs.salesforce.com/en-us/winter20/release-notes/...
1
vote
1answer
35 views

Can we pass a list of id in UserId on a soql query made on UserRecordAccess

I am trying to find access levels on a certain record and this falls in a body of a trigger for which i need to bulkify the data coming in. So is there a possibility of passing a list of ids in the ...
0
votes
1answer
64 views

Mapping two Lists/Sets

I am trying to get my head around mapping two sets (or if this is even the right approach). The objective is to take the name of a custom object (which is currently an email address) and map it to a ...
0
votes
1answer
22 views

Trigger on Account to create case when account customfield is of type Multiselect picklist is updated

I'm having plan__c field on account object.whenever its is updated I want the new values of plan__c is the subject of a case and new case to be created if new values and old values match no case is ...
0
votes
1answer
42 views

How to BULKIFY my code? [duplicate]

I am having a really hard time bulkifying my code, and need to do so becasue I am reaching the SOQL limit on execution. Here is my code as of now. public class Zenefits_Time_Off implements ...
0
votes
1answer
50 views

Mastering Maps: Help needed for bulkifying a simple Opp Trigger Handler

As a beginner I'm currently learning how to bulkify my Apex Classes. I wrote an Apex Class with the following logic: When an Opportunity's stage is changed to Closed Won ... 1. Create an Asset for ...
0
votes
1answer
32 views

How to bulkify a method that queries all the AccountContactRelation relating the Account and Contact Listed in the Opportunity

I need help creating a method that queries the AccountContactRelation object and throws an error when an Opp is created without having an AccountContactRelation between its Primary Contact and Account....
0
votes
1answer
41 views

Insert of ContentVersion not bulkifying properly

I'm currently testing a trigger on ContentDocumentLinks. In order to check in a test class if it bulkifies correctly, I first try to create many contentVersions (so they can the be added to ...
2
votes
1answer
38 views

how to bulkify the next apex code

I got the code below that I had to bulkify it. Basically we need to query campaign share record from a campaign when the cxampaign_approver(lookup to users) field is updated and then remove the manual ...
1
vote
1answer
38 views

How to bulkify Flow call from Apex

I have a process built with a Process Builder. It fires on contact update/create. Under certain conditions that process launches a Flow. Flow accepts two Parameters - ContactId and AccountId. If I ...
0
votes
2answers
75 views

Migration Flow Too Many SOQL Queries

I created a one-time use flow for migration purposes. It looks up all the records to update, and calls a subflow to update each one. The subflow runs 8 or 10 queries and then updates one record. ...
0
votes
1answer
33 views

Use Schema in Trigger

In attempting to "Bulkify" my trigger, it was suggested that I use Schema for getting RecordTypeId. As I'm not really a developer (I'm just taking a stab at updating the code that was created by a ...
1
vote
1answer
62 views

Is my Trigger properly “Bulkified”?

I have a trigger on the Contact object that populates lookup fields from a Custom object (Territory_Reference__c). I'm finding that since this trigger has been put into place, Apex CPU Timeout errors ...
-3
votes
1answer
59 views

Trigger ---I want to delete the contacts in bulkify , but it fails to delete contacts over 600 , error: cpu time timit exceeds [closed]

public class AccountContactHandler2 { //trigger AccountContacttrigger2 //---------------After insert ----------------- public static void createContact(List<Account> acc ){ ...
-2
votes
1answer
49 views

how to aviod soql query in the loop , i have to get get child data in my method

I have 2 object object1 and object 2(related object) ,,,i wrote trigger on object1 when object 1 record gets created user record should get created.. i stored profile perssion set information in ...
0
votes
0answers
29 views

Processing & writing bulkified validation using more than 50k records

I have two fields in my Opportunity object: Phone_1__c & Phone_2__c. Now I have to check to check the whole Org, if there are any opportunities made earlier using any of these two numbers. (Org ...
0
votes
1answer
578 views

“Too Many SOQL Queries” in flow where I need to work with 5000 records

I have a few thousands Contacts and a few thousands Accounts. I need to update a custom field of all my Accounts with Emails of related Contacts. In my flow I get "Error Occurred: Too many SOQL ...
0
votes
1answer
43 views

Help Bulkifying this Opportunity Trigger

I have written the following Opportunity trigger that is working but I know it's definitely not bulkified. It's definitely got some duplication and when any user has any more than 40/50 ...
1
vote
1answer
302 views

Checkmarx Code Quality Warning

After running a Checkmarx scan it returned a code quality warning on a method due to Query: Bulkify Apex Methods Using Collections In Methods. The method is very simple: @AuraEnabled public ...
0
votes
2answers
54 views

I'm having hard time bulkifying a code that attach similar deals to an opportunity when is created

the parameters are: amount within 10% of difference closed won last year Same industry I'm having hard time since is I have to validate 3 parameters instead one. Below you have the non-bulkified ...
2
votes
1answer
134 views

Bulkify Apex Approval.ProcessSubmitRequest

I have an apex class that submits opportunities for approval if they are over a certain threshold. This works great when processing small batches, but when trying to submit larger batches it fails ...
0
votes
1answer
32 views

Help bulkifying a simple trigger

I'm trying to create a trigger that sets a case status to "closed" if there are more than 2 cases created that day associated with the same contact. This is so far what I have written, but I'm ...
0
votes
1answer
255 views

Is UserInfo.getUserId() always the current user where bulkifying needs to be handled?

I know you must Bulkify your code. Does this mean you have to expect UserInfo.getUserId() to be different users? I.E. Can the same trigger can be called on multiple records for multiple users in the ...
6
votes
2answers
70 views

Workaround for the one record at a time trigger invocation when starting from Content Note

I hit this platform problem a while ago Why is this ContentNote trigger receiving 1 record at a time even though multiple records are being inserted?. But today I've hit it again and now I need a ...
-3
votes
2answers
58 views

Bulkifying code

The following is my piece of code, I am trying to bulkify it. Should I define map first and then use the values in insert operation. Please help me. set<Id> DocIDList = new set<Id>(); ...
0
votes
1answer
340 views

How to build a trigger for 2 scenarios in 1 object which will create/update multiple records in another unrelated object?

Scenario 1: a) Trigger on Custom Object 'Prod' only when record type = 'Forecast'. b) It should take data from 1 custom date field and 3 custom number fields in Object 'Prod' c) Then creates 3 ...
0
votes
1answer
30 views

Bulkify Apex class for event object using dynamic soql

I'm trying to get the name of whatId and WhoId on the event object onto a string. I can do it for a single record inside a for loop, the issue I see when Im looking to bulkify the code is that events ...
0
votes
1answer
57 views

How Can i Bulkify my below trigger so that it can handle more than 1 record

trigger AttachmentBeforeInsert on Attachment (before insert) { System.debug('Before insertINg:'); Set<Id> legacyJds = new Set<id>(); Map<Id,Id> legacyIdMap = new Map<...
0
votes
1answer
125 views

MassEmailMessage and “Too many Email Invocations: 11”

I try to test bulk-scenario, but there is an error msg "System.LimitException: Too many Email Invocations: 11". Can I use MassEmailMessage or I need to use only SingleEmailMessage with adding it to ...
1
vote
2answers
150 views

Apex Trigger Update Case With Account Id Bulk

I have created an apex trigger that will update the accountId on the case. I don't think this will work for bulk inserts and was wondering if someone could glance at this and suggest an edit or to. ...
4
votes
1answer
244 views

Why is this ContentNote trigger receiving 1 record at a time even though multiple records are being inserted?

I am seeing a ContentNote trigger called on individual rows even though a bulk insert is done. A stripped down version follows. The debug log output demonstrates that 3 ContentNote objects are ...
1
vote
1answer
87 views

How to bulkify this Apex code?

I wrote the following code, but I know that it is not properly bulkified. I have tried to bulkify it, but facing some issues. Please guide me on how to bulkify this code, so that I can use it as ...
0
votes
1answer
103 views

Bulk flow interviews not interacting with one another

My goal is to run a flow in bulk and not create duplicates. First thing that happens is I lookup colCustomObject. The first interview loops through colCustomObject, determines that a new record needs ...
2
votes
1answer
159 views

Remove SOQL from For Loop

I have 2 custom objects we will call ObjectOne__c and ObjectTwo__c, these 2 objects DO NOT have a direct relationship to each other. However, I have a business need that requires fields on ...
3
votes
0answers
360 views

Bulkify existing flow to avoid SOQL Limits?

I currently have a flow that looks up and passes the ID of a Fire Department into an object called Service Plan. The Fire Department is found by looking up the BillingCity on the Account associated ...
0
votes
1answer
188 views

How to update checkbox bases on values childobject

I have this batchclass where I update a checkbox on account based on related assets. How do I set the checkbox to true If 1 of the assets is true and to false if all assets are false. I would have to ...
-4
votes
2answers
126 views

Merging trigger handlers to handle bulk records?

I have two triggers in Opportunity and these triggers are handler from two different handler classes, now I want them as one class. 1. if(trigger.isAfter){ if(trigger.isUpdate){ ...
1
vote
2answers
78 views

validation to allow only 2 records with same text field value

I need help in following code- I have Custom field on Account as Custom_Id__c(Text 255). Scenario is you can create only 2 accounts with same value in Custom_Id__c field. example - Account 1 - ...
4
votes
2answers
3k views

How many times trigger will be invoked if I want to process 30K records?

As per trailhead module : Bulk Apex Triggers trigger SoqlTriggerBulk on Account(after update) { // Perform SOQL query once. // Get the related opportunities for the accounts in this ...
3
votes
2answers
1k views

How to publish/consume bulkified Platform Events

Use case: External system wants to publish Platform Events to Salesforce. Salesforce wants to consume the Platform Events in a bulkified manner The Platform Events doc offers this REST call: /...
0
votes
1answer
359 views

Insert Bulk Data Received From Web Service

I'm working on a integration project where I'm supposed to get millions of data by doing a callout to a REST API which I then need to insert in a custom object. I'm having issues understanding 2 ...
5
votes
1answer
2k views

How do processes consume SOQL queries?

I'm currently using processes to update records. The ills describing of using the process builder are known to me, but I need more information on how 'Update Record actions' in a process are bulkified....
0
votes
1answer
52 views

Map<string, string> lookup by value

I have a requirement that needs me to do a lookup on a Map based on the value field. The world object has the following structure. Name Type ++++++++++++++++++++++ United States Country ...
1
vote
1answer
272 views

Process builder custom duplication check

I've got an autolaunched flow which run whenever a Custom object adoption is created. The flow then links the adoption to a school, first by searching for one, and creating one if it doesn't already ...
0
votes
1answer
95 views

Get a list of Master records from a list of child records [duplicate]

I'm making a trigger that runs when contacts are updated. Part of that trigger is to get a list of accounts (the whole object, not just the ID) associated with the contacts that are being updated. ...
1
vote
2answers
164 views

Apex Trigger: SOQL query excluding first ever record with filter

I have written following trigger that will tick Duplicate checkbox if a registration record with same client and event already exist. It works but it also ticks Duplicate checkbox if I edit first ...
6
votes
1answer
158 views

Bulkifying trigger on Email Attachments

I created a trigger that copies all incoming email-to-case attachments to Files so that users can select these's files when forwarding emails etc. The code I have so for is: trigger CaseAttachment on ...
0
votes
2answers
954 views

System.ListException: Duplicate id in list

I have a trigger that is a bulk update. Sometimes the same object will make it into my update list more than once, which causes the error: ERROR: autostd2: execution of AfterInsertcaused by: ...
2
votes
2answers
1k views

Can I remove this for loop within a for loop?

The following code is called by an after update trigger on Account. It finds all an account's children Account_Configuration__c records (child name for SOQL is Customer_Credentials__r) and -- if the ...
0
votes
1answer
48 views

Is it possible to trigger bulkify the following?

So I have the following scenario: I upload some data of object A, and within object A there is a field (field_b__c) which I want to use to lookup another object (B) and get a specific field (target__c)...