+ Start a Discussion
Dhruv NirgudeDhruv Nirgude 

i have created one future class so i found one error in Apex Job here is my error notification

ailedFirst error: Update failed. First exception on row 1 with id 0015g00000N8j5YAAR; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, For this particular combination we can not create more than one child record: []

My code
public class AccountCalculator {
    public static void countContacts(List<Id> accIds){
        List<Account> accList  = [SELECT Id from Account where Id IN:accIds];

        for(Account acc : accList){
        acc.Number_Of_Contacts__c = acc.Contacts.size();    
    update accList;

Sai PraveenSai Praveen (Salesforce Developers) 
Hi Dhruv,

There is some validation that an account cannot have more than 1 contact and the account you are updating has more than 1 Contact I hope which is causing the issue. 

You may need to remove that validation or this will be expected behaviour.

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