You need to sign in to do that
Don't have an account?

Why the number of contacts value is not populated in the field ?
public class AccountProcessor { @future public static void countContacts(set<Id> recIds){ List<Account> accs = [Select Id, Name from Account Where Id IN :recIds]; for(Account ac :accs){ ac.Number_of_Contacts__c=[SELECT COUNT() FROM Contact WHERE Account.Id=:ac.Id]; } update accs; } }
I'm try 'Use Future methods' challenge in Asynchronous Apex module. After saving the code and running it in anonymous window, the value is not populated , how can I solve the issue
No it is still not working
Please mark as best answer if the above helps ...!!!
By the way, Doesn't it throw too many SOQL error as the code will create a new SOQL query for every iterations of for loop ?
Please try the below code and it should work as it works for me.
Also, how are you invoking this future method ? from a trigger?
@Vamsi From Anonymous window of Dev Console
No, this code also doesn't work for me. Will there be any interference from other Triggers/Classes/Validation Rule