You need to sign in to do that
Don't have an account?
Mohan Chaitanya Palaparthi
trigger to count no of contacts that an account has
Hi
I have an field Number_of_Contacts on Account Object of data type Number. Can any one give the code to solve this.
Regards
Mohan
I have an field Number_of_Contacts on Account Object of data type Number. Can any one give the code to solve this.
Regards
Mohan
Greetings to you!
Please try the below code, I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
All Answers
Greetings to you!
Please try the below code, I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger CountConOnAcc caused an unexpected exception, contact your administrator: CountConOnAcc: execution of AfterInsert caused by: System.DmlException: Update failed. First exception on row 0 with id 0017F00000ZSYzoQAH; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, account alredy exists same name: []: Trigger.CountConOnAcc: line 25, column 1
You may just disable that validation rule or change its conditions to avoid the error or insert account record with a unique name.
See screenshot:
Regards,
Khan Anas
Thank You
Khan Anas