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
puli rajupuli raju 

query record save and update a record

sandeep sankhlasandeep sankhla
Hi Puli,

So lets take an example if you want to query account records and then you want to update the same then following is code you shoudl be using to achiev this.

In your class or trigger whereever you want to do thuis operation.
list<Account> lastAccToUpdate = new list<Account>();

for(Account objAccount : [select id, Name from Account limit 10])
      objAccount .name = 'TestName';
      lastAccToUpdate.add(objAccount );


update lastAccToUpdate;

in above code I am getting 10 account records from query and then I am updating tehir name.

Please try and let me knwo if you have any other question or doubt.