function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
shailendra singhaishailendra singhai 

How to bulkify the code for before insert

hi,

Could you please help me to make the code bulkify, currently it is hitting governor limit for fetching more then 50001 row.
Issue/ Description:
i have on custom object ABC__c  which contain  20000 record's (having detail of name and phone number)
while creating lead i need to check if the lead(first name/ last name or phone number) present in the ABC__c object, one check box present__c on lead should get 'TRUE' and one comment field should update with matching criteria in lead itself.
i follow the below steps.
1. i have created trigger upon lead before insert, call the class by passing the lead in trigger.new
2. SOQL query to fetch data from ABC__C, create two set  one for phone and one for name
3. itrating the trigger.new record(lead record)
4. if match found keeping the check box true and comment field with comment.

it is working perfactly fine when we enterrecord manually.
but when use dataloader it break with governor limit.
could any one suggest in which step i am missing.

when we run with batch size two in dataloader it works but it takes two much time.
can you suggest for batch of 200 in dataloader ABC__C 20K record should call only once...

Thanks in advance



 
RKSalesforceRKSalesforce
Please share your trigger code.