You need to sign in to do that
Don't have an account?
Matt Folger
Collection size 1,321 exceeds maximum size of 1,000.
I looked at the other posts with a similar issue and didn't find what looked like my problem there.
I have a user-driven SOQL query, and now that I've loaded a larger data set in the App (via dataloader.io, FYI) I'm seeing this problem whenever i run a query.
Help!
I have a user-driven SOQL query, and now that I've loaded a larger data set in the App (via dataloader.io, FYI) I'm seeing this problem whenever i run a query.
Help!
The query should be like this -
SELECT name, Inquiry__c, Inquiry_Status__c, Product__c, PO__c, Vendor__c, Inquiry_Date__c FROM Vencorr__c WHERE Inquiry_Status__c like '%Original%' AND Inquiry_Date__c = LAST_N_DAYS: 180 LIMIT 1000
So keep the as it was. Do not change anything. Except this -
Add a line before Database.query statement. querString += ' LIMIT 1000'
Please try out the code below.
Thanks,
Kaustav
All Answers
If you are not doing that and you are receiving the error in your controller, then I would suggest you check the API version of the controller.
Thanks,
Kaustav
Ok, is there a quick SOQL way to just limit the query to 1000 records? That's probably the easiest way to do it. Although there is plenty more than 1000 records in the entire object I doubt the users would ever need to see more than 1000 in a query view.
Thanks,
Gaurav
Weird.
The same limit does not hold true for Apex so that's why I'm assuming it's a VF issue.
You can get around this by generating a List of Lists of Sobjects. Essentially, you'll break the records into chunks of <= 1000 and using nested repeats, you would iterate through them.
This is pretty sloppy, but what your Apex may look like:
Then in your VF you could do:
ERROR
Error:
unexpected token: LIMIT
Kaustav, do you have any advice on why that might be happening?
James, I'll have to play around with that code you provided and see if I can get it working.
Thanks everyone for all your help. I continue to be surprised by everyone's generosity here.
Please do a system.debug and print the query string. Post it here from the debug logs. We will be able to figure out the issue. If possibly provide the code and we will be able to solve it.
Thanks,
Kaustav
queryString = 'SELECT name, Inquiry__c, Inquiry_Status__c, Product__c, PO__c, Vendor__c, Inquiry_Date__c LIMIT 1000'+
'FROM Vencorr__c ' ;
I changed to this:
queryString = 'SELECT name, Inquiry__c, Inquiry_Status__c, Product__c, PO__c, Vendor__c, Inquiry_Date__c'+
'FROM Vencorr__c LIMIT 1000' ;
Now it says: ERROR
Error:
unexpected token: WHERE
queryString = 'SELECT name, Inquiry__c, Inquiry_Status__c, Product__c, PO__c, Vendor__c, Inquiry_Date__c'+
' FROM Vencorr__c LIMIT 1000' ;
There should be a space between the last field name and the FROM key word.
Thanks,
Kaustav
if (Ven_Inquiry != null && Ven_Inquiry != ''){
string tempVen_Inquiry = Ven_Inquiry;
tempVen_Inquiry = String.escapeSingleQuotes(tempVen_Inquiry); //To avoid SOQL injection
tempVen_Inquiry = tempVen_Inquiry.startsWith('%') ? tempVen_Inquiry : '%' + tempVen_Inquiry;
tempVen_Inquiry = tempVen_Inquiry.endsWith('%') ? tempVen_Inquiry : tempVen_Inquiry + '%';
queryString += whereOrAndClause() + ' name like \''+tempVen_Inquiry+'\'';
}
????
Could that be part of it?
The format should be SELECT Id, name, etc... FROM Object WHERE Conditions... LIMIT 1000
In your code you must have executed something like this - Database.query(queryString);
What would be really helpful is if you can give a system.debug('#### final query string #### ' + queryString); just before that statment.
Then we will get to see the entire query that is being formed. If possible post the code and the debug then we can solve the issue.
Thanks,
Kaustav
SOQL: SELECT name, Inquiry__c, Inquiry_Status__c, Product__c, PO__c, Vendor__c, Inquiry_Date__c FROM Vencorr__c LIMIT 1000 WHERE Inquiry_Status__c like '%Original%' AND Inquiry_Date__c = LAST_N_DAYS: 180
The query should be like this -
SELECT name, Inquiry__c, Inquiry_Status__c, Product__c, PO__c, Vendor__c, Inquiry_Date__c FROM Vencorr__c WHERE Inquiry_Status__c like '%Original%' AND Inquiry_Date__c = LAST_N_DAYS: 180 LIMIT 1000
So keep the as it was. Do not change anything. Except this -
Add a line before Database.query statement. querString += ' LIMIT 1000'
Please try out the code below.
Thanks,
Kaustav