You need to sign in to do that
Don't have an account?
vijay kumar k
count no of contacts under account using batch class
write batch class to update field(noofcontacts__c) value on account with No of Contacts under that account.
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
Here is a simple way to wrap this up in a Batchable. All the Batchable mechanism is being used for is to divide up the Accounts into blocks. If you have only a small number of Contacts per Account you can run this with largish batch size, say the default of 200. But if you have more than 50,000 Contacts related to any Account this will still fail with even a batch size of 1 because the governor limits apply to each execute method call.
To run the Batchable it's:
Database.executeBatch(new MyBatchable(), 50);
where the last argument is how many Account object to pass per call of the Batchable's execute method.
Hope this helps.
Kindly mark this as solved if the reply was helpful.
Thanks,
Nagendra
All Answers
Here is a simple way to wrap this up in a Batchable. All the Batchable mechanism is being used for is to divide up the Accounts into blocks. If you have only a small number of Contacts per Account you can run this with largish batch size, say the default of 200. But if you have more than 50,000 Contacts related to any Account this will still fail with even a batch size of 1 because the governor limits apply to each execute method call.
To run the Batchable it's:
Database.executeBatch(new MyBatchable(), 50);
where the last argument is how many Account object to pass per call of the Batchable's execute method.
Hope this helps.
Kindly mark this as solved if the reply was helpful.
Thanks,
Nagendra
If you want to get the no of contacts in account by using batch class.
Please have a look at this link:
https://salesforce.stackexchange.com/questions/81765/batch-apex-for-counting-number-of-contacts-associated-with-account
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
Can you please help me to solve it