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
raj123raj123 

How to Store and Update the List more that 1000 rows

i have a need to Update more that 5000 records at a time, so i am storing the records in a List and updating but there is a limit that list cannot store more that 1000 rows.

 

Can any one help me with a code snippet to ccomplish this task 

 

Currently i am doing like this 

 

selectedjobs is a list of type jobwrapper

 

for(JobWrapper on : GetWrapperData())
{
if(cCon.isSelected == true)
{
selectedJobs .add(cCon.jb);
}
}

 

saving the changes

 

for(Job eq:selectedJobs)
{
Job eqsObject=new Job (Id=eq.id);
eqsObject.No=code;
lstEqRec.add(eqsObject);
}

 

updating 

if(!lstEqRec.isEmpty())
{
update lstEqRec;
}

 

Best Answer chosen by Admin (Salesforce Developers) 
kennedymankennedyman

joshbirk may be on to something.

 

It may be a visualforce error and not an Apex one. I believe more visualforce elements won't allow more than 1,000 rows to be displayed. 

 

But you should be able to update up to 10,000 records with just Apex.

 

Alternatively, you could turn your method into a webservice and use javascript or some other language to do calls in batches.

All Answers

kennedymankennedyman

I'm not sure what the problem is, the limit for updating records via DML statements is 10,000.

 

And there hasn't been a 1,000 limit on lists for quite some time.

 

EDIT: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_gov_limits.htm

joshbirkjoshbirk

Are you passing it down to Visualforce?

kennedymankennedyman

joshbirk may be on to something.

 

It may be a visualforce error and not an Apex one. I believe more visualforce elements won't allow more than 1,000 rows to be displayed. 

 

But you should be able to update up to 10,000 records with just Apex.

 

Alternatively, you could turn your method into a webservice and use javascript or some other language to do calls in batches.

This was selected as the best answer
joshbirkjoshbirk

Yeah, exactly.  Apex/DML isn't restrained by the array size as much as Visualforce is - but you could chunk Visualforce requests back and forth until Apex has what it needs to get the job done.

 

JavaScript Remoting might also be a solution here.

raj123raj123

i am not using this list in visualforce , i am saving the the rows returned from the database. query to a list,  

 

My doubt is i have written code to update all the records that are returned from the query and i have limited the query to 50000 rows ,  

 

so is it possible to update all the records in the list at once with single update statement. 

nagalakshminagalakshmi

Hi Raj,

 

Use the batch apex class for updating the records more than 10000. By using normal apex class it is not possible to update morethan 10000 records. 

 

Thanks

raj123raj123

Thanks, All