Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Make your voice heard. Take the 2019 Developer Survey now

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).

0
votes
1answer
8 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
22 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
25 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
29 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
49 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 ...
-2
votes
2answers
35 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
51 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
22 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
51 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
38 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
58 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. ...
3
votes
1answer
121 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
52 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
82 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
77 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
191 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
38 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
71 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
51 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
1k 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
476 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
192 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 ...
3
votes
1answer
838 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
43 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
90 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
38 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
85 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
116 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
414 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
47 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)...
0
votes
2answers
67 views

Bulkify Scheduled Apex Class

I have just created my first scheduled Apex Class and need a bit of help with the "bulkification" process. Objective: My scheduled Apex Class is designed to update a datetime field on each Contact ...
0
votes
1answer
16 views

Opportunity Owner not set using apex trigger in bulk

Following trigger code not set opportunity owner based on opportunity's account billingCountry, it is working when i inserted single record but it's not working in bulk data import. All record get in ...
0
votes
1answer
106 views

Insert using Bulk API throws error MISSING_ARGUMENT:fiedXXX__c not specified:--

An external system is using bulk api to insert records in Salesforce. Salesforce throws an error saying - MISSING_ARGUMENT:fiedXXX__c not specified:-- where XXX is external Id of Parent of the ...
0
votes
1answer
195 views

Bulk merge of Contacts across different Accounts

I've created a class to manually do a mass merge of Contacts from different Accounts, creating AccountContactRelation records between the new master Contact and Accounts from the duplicates. Due to ...
0
votes
2answers
420 views

How do I do bulk update to external web via REST api?

I have a REST API callout to our website to update data (eg Account) there from our Salesforce instance. This is all working fine doing 1 Account when it's created or updated as the trigger does the @...
0
votes
1answer
165 views

Apex/SOQL - Parent - Child - Grandchild join and insert into another object

My background is SQL & am finding challenging while handling some scenarios in SOQL. Here is my scenario: We have 3 objects that are related (Parent_Obj -> Child_Obj -> Grand_Child_Obj). We ...
1
vote
1answer
332 views

Dynamic field set with mass update

We have a VF page that allows users to mass update cases based on whatever fields are on the page. The page displays a temp case whose values are then applied to the list of selected cases. We ...
1
vote
2answers
53 views

Bulkification help with apex called from trigger

I am slowly learning Apex and have created the following method called from a trigger to update the work order address fields by copying the data from a related address object. As I now understand it,...
1
vote
1answer
454 views

Creating a Map with String, Object combination

I have a List of String. This list consist of accountNumbers from Account Object. List<String> accountNumList. I have a child object XYZ__c, which is child of Account Object. XYZ__c object has a ...
1
vote
3answers
172 views

Assistance to Bulkify this class processing custom objects

My org uses custom revenue schedule objects created via triggers and classes running off of the Opportunities. It is very complex (beyond my scope for updating in any reasonable time) - it uses a ...
1
vote
1answer
103 views

Inserting record using Test Class vs data loader

I have a situation where I need to test whether the apex classes written in my org does not hit governors limit / anyother issues when bulk data is loaded. I decided to use test class to check this. ...
2
votes
1answer
349 views

Bulkify SOSL query in loop

I'm trying to build a process which looks up a matching account for a lead, given a cleaned email or website. The issue I'm facing is that this could be run against 1000 or 10k leads at once and the ...
2
votes
1answer
65 views

Trigger Traverse through 5 objects's collection in SOQL without inner for loops

Team Seller Servicer Assignment is a junction object between Team and Account. Team Membership is a junction object between Team and User. I need to write two triggers, one whenever a Team Seller ...
5
votes
1answer
301 views

Bulkified generation of unique 6-character alphanumeric IDs, with strict validation criteria

I have a requirement to generate a unique 6-character alphanumeric ID for records on a bulkified before-insert trigger, on an object already containing about 5 million records and expected to grow to ...
3
votes
1answer
260 views

Unable to Add Child Object to a Parent Object List?

I queried a the parent object and its Kid(Kid__C). Assigned it to a list of Parent object: List<Parent__c> p = [SELECT id, name (SELECT id, name FROM kids__r order by CreatedDate DESC), ...
1
vote
1answer
479 views

Scenarios where trigger will be more suitable than Process Builder [closed]

I would like to know when we should prefer using triggers over Process Builder? Also is their any bulkification limit for Process Builder? Also if we can only query 10,000 records in apex, then is ...
1
vote
1answer
593 views

Connecting fields in two List of objects

I have two list of object. List<ClassA> and List <ClassB>. ClassA has a field TextA and ClassB has a text field TextB. I want to copy the TextB value to TextA for each object of ClassA. ...
2
votes
3answers
2k views

Process builder and lack of bulkification

What is a valid robust use case for Process Builder when doing record updates? I've been running into an issue recently where every record update causes 1 SOQL and 1 DML per record which meets the ...
0
votes
1answer
31 views

Null values for one custom field

I have below trigger block. I am getting null values for dsrl.Related_Opportunity_del__r.Business_Group__c. if(Trigger.isbefore && (Trigger.isInsert|| Trigger.isUpdate)){ System.debug(...