You need to sign in to do that
Don't have an account?
sudhirn@merunetworks.com
Load Query Count into a variable
Hi Experts,
Below code is working fine have no problem because of this too many queries am gettin 50001 issue when migrated to production
Is there any alternative way to load the query count to the variable please suggest me
Thanks
Sudhir
Below code is working fine have no problem because of this too many queries am gettin 50001 issue when migrated to production
Is there any alternative way to load the query count to the variable please suggest me
String query = 'SELECT Id, Name, OwnerId, Owner.Name, NextStep, StageName, Total_List_Price_Amount__c, ForecastCategoryName, '+ 'CloseDate, Amount,Formula_Amount__c,(Select Id,Name,Status__c from SPR__r ORDER BY CreatedDate DESC LIMIT 1) '+ 'FROM '+ 'Opportunity '+ 'WHERE '+ 'Id != null'; List<Id> listOppIds = new List<Id>(); //List<Opportunity> CountOppRecords = Database.query(query); total_size = CountOppRecords.size();
Thanks
Sudhir
Integer i = Database.countQuery(QueryString);
Too many query rows: 50001
1) Setting Read-Only Mode for an Entire Page / Setting Read-Only Mode for Controller Methods
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_readonly_context_pagelevel.htm
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_readonly_context_methodlevel.htm
2) Batch class
//Execute batch
Database.executeBatch(new CountOpp(), 2000);
3) Using Rest API
Hope it helps!