You need to sign in to do that
Don't have an account?
Lee Sin
Do I Need to use Batch Apex here, if so how can I use batch apex?
I have two types of Account, advisor and client. Each advisor has 3000 clients. I want to get the 75 random clients and use their ids to create 75 tasks. //1 query 36 result rows List<Account> advisors=[select id,account_type__c,client_territories__c from Account where account_type__c='advisor']; for(Account a : advisors) { //result rows too large, over 50000 //For each advisor, create a list of its clients Account List<Account> clients=[select id from Account where client_territories__c=:a.client_territories__c]; //Here I want to randomly pick 75 Account Ids and use that as whatid to create 75 Tasks //If I use the "Limit" Key word in the query, it will not generate random records right? }
All Answers
I modified my code to avoid using query inside a for loop.
But Still got error.
Line 23 gives me too many result rows 50001