You need to sign in to do that
Don't have an account?
jishan 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.
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.
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,
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)