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
3 votes
1 answer
2k views

Bulkification of SingleEmailMessage

I'm trying to bulkify my code, and send all emails out as part of a list however I'm receiving the following error; Method does not exist or incorrect signature: [List].setTargetObjectId(Id) What ...
Glenn Daly's user avatar
0 votes
1 answer
20 views

bulkification issue for insert operation of attachment

I am getting bulkification issue on "insert at".Not able to understand why there is bulkification issue.Below is my code. public static Attachment addAttach(Attachment at) { try { ...
Jack vardy's user avatar
5 votes
2 answers
10k views

Update records using map values

Sorry for the beginner question -- I'm generating a Map<ID,String> where the ID is an OpportunityId and the String is the value of a custom field on the Opportunity that I want updated. How ...
Matt's user avatar
  • 1,017
0 votes
1 answer
2k views

custom setting in Apex Trigger [closed]

I have one custom setting country name and capital. I have created a one trigger which will set the description(capital) based on country_Information picklist. trigger FetchCapitalUsingCustomsett on ...
ajay bagdad's user avatar
1 vote
3 answers
3k views

Comparing two field name in two lists

I'm comparing two list given in the list to see if the item.name exists in both for loop. If not then add into a list to show the error for the missing names. set<id> setAssetIds = new set<...
Nick's user avatar
  • 7,002
0 votes
1 answer
817 views

Roll-up summary field not update when insert parent & child records at same time

I have written trigger on child object for calculating rollup summary. Whenever child record insert, update or delete the sum of all child record tax value update in parent record. Code Snippet: ...
Murali Mohan Mandadi's user avatar
0 votes
1 answer
1k views

User Trigger - Public Group Membership

I need some help with a trigger. I want the role to dictate what public group a user is made a member of. I am trying to write this as a bulkified trigger using good SOQL form where there aren't any ...
Matt M's user avatar
  • 1,477
0 votes
2 answers
67 views

Error in Bulk Pattern SOQL

I am getting an error in the for loop. Error: Variable does not exist: acclist public class AddPrimaryContact implements Queueable { Private Contact conl = new Contact(); Private String sty; ...
SFDC_BigDog's user avatar
0 votes
2 answers
45 views

Bulkified Trigger - Review

Can a few people give this a look over and see if I am properly bulkifying this trigger? It is a simple trigger designed to update the Name field on other records that lookup to these records. ...
Matt M's user avatar
  • 1,477
0 votes
1 answer
77 views

Need help in bulkifying my trigger code

Background Scenario : I have to insert records in a object through X-author file. This file may contain duplicates and I have to avoid duplicate insertion. Duplicates are considered on the basis of ...
Ruchi's user avatar
  • 1,515
2 votes
1 answer
145 views

Bulkify trigger by removing soql from for loop [closed]

I have belowtrigger which i need to optimize it to support bulkification.But getting error on line List<Account> accounts = [SELECT OwnerId FROM Account Where Customer_ID__c =: custMap.get(inv....
Jack vardy's user avatar
-4 votes
3 answers
106 views

Bulkification issue-System.LimitException: Apex CPU time limit exceeded trigger

Below is my trigger.I am getting bulkification issues.If the number of records of object Sales_Quota__c is huge then on dummy update of invoice records i am getting error in trigger saying "...
Jack vardy's user avatar
-1 votes
1 answer
49 views

Can any one help me how i will bulkify my trigger [closed]

/* Name - ConatctAccountTrigger Purpose - Contact records will be created via data loader. This trigger reads Buyer ID and ASAP Tower ID from contact, searches account for ...
Santosh Sahani's user avatar
0 votes
1 answer
30 views

Need help with bulkifying code [closed]

global with sharing class LOYMemberServcies { public Map<Membership_card__C,Member__c> postMemberEnrollmentActivities(Map<String,Member__C> newMem) { //Get the base tier system....
JJoseph's user avatar
  • 491
1 vote
1 answer
71 views

Why My Apex Trigger doesn't support Bulk Upload (Batch>1)

May be somebody can explain me. Story: I have a Separate Custom Object for SIC codes (SIC_Lookup__c). It is linked to Account Object with a [Account].SIC_LkUp__c Look Up field. I want: When standard [...
Vasiliy Vasilev's user avatar
0 votes
1 answer
42 views

How to bulkify a cross object update trigger

I have a complicated trigger that I am trying to bulkify but I don't know how to go about it. We have two main objects, Prescriptions and Study Participants. When a new Prescription is added through ...
Melissa Lenai's user avatar
2 votes
1 answer
163 views

How to Bulkify when each record has different combination of values in a transaction?

Could somebody please help me on how to write a proper Bulkified trigger for the below scenario. Please note that I am not new to the trigger Bulkification but I am just struggling to write an ...
javanoob's user avatar
  • 8,847
1 vote
2 answers
115 views

Bulkify SOQL-Query in Trigger to search for duplicate objects

My trigger fires on my CustomObject ProductionOrganizer__c and searches leads with the same E-Mail or same LastName && Company (The object therefore has a field for email, lastname and company)...
Jannis Lietzau's user avatar
2 votes
1 answer
169 views

How to Query for dupe leads in Bulk with Mapping?

Goal: 'Bulkify' the existing Apex trigger used for counting how many dupes a Lead had, and inserting the Contact Id of the Contact record (if more than one, the first in the list) that matched the ...
GPP's user avatar
  • 553
1 vote
1 answer
33 views

Create list of Master-Objects for Detail-CustomObject and add Lookup to Detail

I want to create a Lead, based on the data in my custom Object ProductionOrganizer__c. The ProductionOrganizer has a lookup-field AttachedLeadId__c where it can be linked with a lead. Now when ...
Jannis Lietzau's user avatar
1 vote
2 answers
70 views

How to manage multiple data in input with a Bulk

I've got this problem to solve. I've an apex batch that updates some records all together when a condition is verified. This triggers a Process builder that calls an Apex Class or whatever it might ...
Fabio Maturo's user avatar
1 vote
1 answer
84 views

How does a trigger behave

Assume I have written a after insert trigger on an object A. I do some manipulation inside my trigger and at the end I create 3 to 4 new objects , that is a related list in Object A(Master-detail ...
SfdcBat's user avatar
  • 4,791
3 votes
1 answer
246 views

SOQL returning last modified contact matching each email address in set

I am trying to bulkify a trigger to match transactions with contacts by email address. There are many contacts with duplicate email addresses and getting rid of these duplicates is not an option. I am ...
Sequoyah's user avatar
  • 760
2 votes
2 answers
260 views

Trigger Help: Update Custom Email Field based on Value in Lookup Field (Lookup to User) Using Trigger

I am new to Apex and would like to practice updating a custom email field which derives its value based on a custom lookup field. I understand this can be done with a simple formula, but want to ...
VMF's user avatar
  • 23
1 vote
1 answer
805 views

Bulkify the code?

I want to clone the Opportunity record if some conditions satisfied in Opportunity car set which is in related list. Opportunity (Master)--->Opportunity car set(Child) My below code is working fine....
uma451's user avatar
  • 809
0 votes
2 answers
97 views

Too Many SOQL Queries: 101 - trigger

I am getting error message and I believe it to be error with this trigger. I am new to coding and this was done previously so any assistance is greatly appreciated trigger setAttendeeNumbers on ...
user29991's user avatar
3 votes
1 answer
241 views

Trigger Best Practices

How would you rewrite the following trigger to follow best practices re: bulkification, etc? trigger Order_PopulateGallery on RH_Order__c (before insert, before update){ List<Account> accs = ...
vshake's user avatar
  • 99
0 votes
1 answer
395 views

Help in bulkify trigger to camelcase fields in accounts

I have created the following trigger with the main purpose of camel case some fields in the account object. However it seems to be breaking when I do bulk uploads (uploading business and person ...
manza's user avatar
  • 1,953
1 vote
1 answer
1k views

Process Builder vs Apex Trigger

I had the following two requirements to implement. Change account type field on account as soon as a first opportunity is added to that account. Change account type field on account as soon as ...
Abhiram Sheshadri's user avatar
3 votes
3 answers
1k views

Choosing Bulk Count in test classes

Salesforce recommends that we test the code in bulk, especially triggers. So we are expected to insert, update and delete records in bulk inside the test classes as per good coding standards. My query ...
Prajith's user avatar
  • 1,559
1 vote
0 answers
157 views

Is this a fair bulkification of getContentasPDF?

I have to bulkify a handler which utilizes getContentasPDF method. Initially I was passing only single record id in the future method. Now I am passing set<Id> as parameter in savePDF which is a ...
Jarvis's user avatar
  • 2,110
0 votes
0 answers
47 views

Efficient bulkification of callouts

I have a requirement to update a property at the geolocation of an account record. Decided that triggers or any synchronous apex isn't the way to go forward primarily due to governor limits. I would ...
Prajith's user avatar
  • 1,559
0 votes
1 answer
483 views

AutoFollow using EntitySubscription

I'm trying to write a bulkified logic for a problem on entity subscription. I've a custom object Student which has custom lookup field to User named as Mentor. The use case is when the mentor field is ...
Sagnik's user avatar
  • 595
0 votes
0 answers
137 views

Update Object with unique values from Child object using Aggregate result

I am trying to update a field on the Quote (Operational_Start_Date__c) from the results of an aggregate result query. The trigger runs on quote, queries QuoteLine for unique values and update the ...
Kenn K's user avatar
  • 885
3 votes
1 answer
90 views

Help to Bulkify This -

I have the following method called from a trigger, which calls another method which has SOQL in it. I want to remove that query from the method so that I will not face governer limits issues in the ...
Salesforce Steps's user avatar
1 vote
2 answers
68 views

how to write trigger for bulk records

I tried this by using this inserting, updating employee record. My task is if employee test__c is equal to contact__c test__c employee is automatically created as that contact child if no contact with ...
user123's user avatar
  • 271
2 votes
1 answer
244 views

Bulkify SOQL with multiple date comparisons

I am just starting out with apex and learning about bulkifying queries but I bumped up across a query that I am not sure how to bulkify. What I am trying to do is return a Count of the number of ...
asielen's user avatar
  • 49
4 votes
1 answer
1k views

How to bulkify a trigger that is having a method to call a future method?

I am having a trigger on Case object. The objective of the trigger is to create a Service Notification record in SAP. As the best practices suggest that we need to bulkify the trigger to avoid ...
Bforce's user avatar
  • 6,828
1 vote
1 answer
344 views

How to resolve Bulkify apex methods using collections in methods (Chckmarx issue)? [closed]

I have submitted my code for security review and got a few warnings for the Bulkify Apex Methods Using Collections In Methods. I have read the code best practices and also some stack exchange posts ...
Vignesh Damodharan's user avatar
7 votes
2 answers
310 views

Is it advisable to avoid bulkification in a trigger on attachment object?

I'm required to change the title of each attachment on an upload to the name of the expense item. I have written a bulkified code trigger ExpenseProof on Attachment (before insert) { set<id&...
Jarvis's user avatar
  • 2,110
0 votes
0 answers
1k views

Flows - Possible To Use Loops with Null Collections?

I have a loop and inside the loop there is a decision and two assignments. The assignments should only be executed if the loop variable is null. However, if the collection is null then there is ...
Jay's user avatar
  • 676
1 vote
1 answer
6k views

Comparing Strings / using LIKE in an if statement

I have an interesting issue: I have a custom object record created with a String for a client Name. I then have to compare that String to Account.Name. If match, add it to a wrapper. I use SOQL to ...
RC82's user avatar
  • 595
0 votes
2 answers
126 views

Workaround advice for "Too many SOQL queries"

We are a vacation rental management company with 70 properties. I am trying to write a schedulable apex class that will scan through each Property__c to retrieve the next arriving Account (70 queries) ...
Alex Brigham's user avatar
  • 1,139
-1 votes
3 answers
176 views

Getting DML limit error in apex trigger

I have a batch class which runs to delete old records, which in turn triggers a trigger on before delete. Now when the trigger runs it hits dml limit as calling class dml statements is running inside ...
sfdc_to_learn's user avatar
0 votes
1 answer
63 views

How to bulkify this code

The below code working and doing what is suppose to do but I know that the below code is not optimized/bulkify, how can I bulkfiy this code public void SchedulingClass(List<Reading__c> reading) ...
Nick's user avatar
  • 7,002
2 votes
1 answer
137 views

Will the upcoming 'bulkifying' improvements to the process builder solve this issue?

I have a headless flow that runs when a new user is created*. It looks up the users email address via a record lookup/contact search. If no contacts exist with that email address a new contact is ...
Jay's user avatar
  • 676
5 votes
1 answer
233 views

Can I Bulky this further?

Is there any way to bulkify this more? Here is the code trigger CreateCampaignMemberBulkify on Contact (after insert,after update) { // Creating a container List<CampaignMember> allCM =...
Julie Davison's user avatar
-1 votes
1 answer
45 views

Apex trigger: Bulkification code problem

Is there a way to bulkify the below code? If we do a mass update of certain parts, its giving us too many queries. for(Part__c p:Trigger.new){ List<Sampling__c> sampList = [SELECT Part__c ...
Gops's user avatar
  • 367
0 votes
2 answers
46 views

Can I reduce the number of containers and (seemingly) redundant loops when querying parents and grandparents?

tl;dr - I'm retrieving fields on an object, the object's parent, and the parent's parent in a trigger - is there any way to make my code use less than 5 containers and remain bulkified? I have an ...
Brian Mansfield's user avatar
2 votes
1 answer
2k views

Why this strange behavior in the Salesforce debug logs? The query executed twice: 1 returng results and another one returng nothing

I am writing a trigger to update the child of a parent in case a specific field on the parent has changed. The problem is I get a query with 0 results. After looking on the debug logs, the SOQL ...
Dan Melt's user avatar