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
jishan royjishan roy 

how to update multiple contact record in account record page by using apex class

here is my code:
public with sharing class contactController {
    @AuraEnabled(cacheable=true)
    public static List<Contact> getContacts(String accId) {
        return [
            SELECT AccountId, Id, FirstName, LastName, Title, Phone, Email
            FROM Contact
            WHERE AccountId = :accId
             
           ];
       
    }
}


it will not working for updating multiple record on table.
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Jishan,

The above code only gets the Contacts related to the Accountid. There is no logic to update the contact information. You need to iterate through the list and update the contact.

If this solution helps, Please mark it as best answer.

Thanks,
 
McCuboMcCubo
Hi jishan,
You are not performing any update operation over the record set. If you want to update the records returned by the query, first thing is to remove the cacheable=true option from the @AuraEnabled annotation, since setting that option to true, a method must only get data. It can’t mutate data. as statated on this article (https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/controllers_server_apex_auraenabled_annotation.htm)