You need to sign in to do that
Don't have an account?

Error: Too many SOQL queries :21
Code:
trigger Ph1_calculatefieldLead on Lead (after update,after insert) { //Lead [] le=Trigger.new; Integer TotalPassToSales=0; String LeadsViaCamapign='0125000000010WY'; String NonCampaginLeads='0125000000010WT'; for (Lead leLoop:Trigger.new){ Integer CountCampaignPresent=[Select Count() from CampaignMember where LeadId=:leLoop.Id]; //leLoop.adderror('e'+CountCampaignPresent); if(CountCampaignPresent==1){ /* Select campaignid of linked Campaign */ String LeadCampaignId=[Select CampaignId from CampaignMember where LeadId=:leLoop.Id].CampaignId; /* Select all LeadIds of Leads linked with a particular campaign */ //CampaignMember [] LeadCampaignMember=[Select LeadId,CampaignId from CampaignMember where CampaignId=:LeadCampaignId]; for(CampaignMember LeadCampaignMemberLoop:[Select LeadId,CampaignId from CampaignMember where CampaignId=:LeadCampaignId]){ /* Check LeadId is not null */ if(LeadCampaignMemberLoop.LeadId!=null){ /* Select information about Lead linked with a particular Campaign*/ Lead LeadCampaignLoop=[Select Status,lead_internal_lead_status_pck__c,RecordTypeid from Lead where id=:LeadCampaignMemberLoop.LeadId]; /* Calculate Total Pass To Sales Leads */ if(LeadCampaignLoop.Status=='Open - Passed to Sales' || LeadCampaignLoop.Status=='Closed - Accepted by Sales' || LeadCampaignLoop.Status=='Closed - Rejected by Sales' ){ TotalPassToSales=TotalPassToSales+1; } } } /* Select campaign for Lead whose status is changed */ Campaign camp=[select cam_tot_pass_to_sales_lead_num__c from campaign where id=:LeadCampaignId]; /* Populating values into concerned fields of Campaign */ camp.cam_tot_pass_to_sales_lead_num__c=TotalPassToSales; } }
hi all,
i tried to import 18 leads through data loader without any information about campaign.
i am getting error too many SOQL queries :21 at line ::::::Integer CountCampaignPresent=[Select Count() from CampaignMember where LeadId=:leLoop.Id] during after update .
it is also saying 'data already exists' but no leads were present before importing.
please help me out.
please help me out.
regards,
mahi
Alert: All information in the import file was already in Salesforce.
Result: No data was created or modified in Salesforce.
20 values: unexpected errors. Line number(s): 2, 3, 4, 5, 6, 7, 8, 9, 10
If you encounter any problems or have any questions, please contact us by clicking Help & Training at the top right of any Salesforce page and choosing the My Cases tab.
hi all,
All Answers
Dear Friends,
I am also facing this peculiar problem.
Does this mean that Triggers dont work well with Batch Load of data like though Apex Data Loader/Import Wizard?
Steve
Thanks Steve....
I understood your point. But we are new to this concept of Bulk Triggers Execution. I have gone through the Apex documentation. But was not able to relate well with our requirement.
Can you suggest some sample code apart from what is given in the Apex document?
Would be really helpful....
Thanks,
CD
Set<ID> OppID = new Set<ID>();
do not put sql inside for loop. Play with ids.
Do not put sql in loop neither update in for loop. while updating create array of objects and then add modified objects in that array inside for loop. Then update the whole array outside the for loop.
Thanks
Alert: All information in the import file was already in Salesforce.
Result: No data was created or modified in Salesforce.
20 values: unexpected errors. Line number(s): 2, 3, 4, 5, 6, 7, 8, 9, 10
If you encounter any problems or have any questions, please contact us by clicking Help & Training at the top right of any Salesforce page and choosing the My Cases tab.
hi all,
I bet the error has to do with the batch size you are importing.
If the import file is greater than 20 records, batch settings in data loader.
If you are using import wizard, turn off the trigger temporarily.
I just had to deal with that email and this fixed it!
Best regards,
Alan Marcus