function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
John_SFDCJohn_SFDC 

Count the contacts associated with Account with condition

I have two checkboxes(Stu__C,CLS__C) on contact object and two number(X_count,Y_count) fileds on account object.
X_count : contacts where Stu__C is not checked,
Y_count :contacts where CLS__C is not Checked.

I need to calculate the Stu__C unchecked contacts associated with an account and that count i have to show on X_count(Account). (like Rollup summery)
I need to calculate the CLS__C unchecked contacts associated with an account and that count i have to show on Y_count(Account). (like Rollup summery)

Thanks in advance
Mahesh DMahesh D
Hi Muneendar,

You can do the same with Process builder. Please check below post i hope that will help you
Option 1:- Process builder
1) https://developer.salesforce.com/forums/?id=906F0000000BHvJIAW
2) https://developer.salesforce.com/forums/?id=906F0000000B2C0IAK

Option 2:- Trigger
1) http://blog.jeffdouglas.com/2011/08/23/salesforce-trigger-when-rollups-summaries-not-possible/
2) https://success.salesforce.com/answers?id=90630000000h3mNAAQ 
3) https://developer.salesforce.com/forums/?id=906F00000008yWuIAI
4) https://github.com/abhinavguptas/Salesforce-Lookup-Rollup-Summaries
5) http://www.iterativelogic.com/developing-custom-apex-rollup-summary-field-logic/

Also look into the below explanation:

To calculate Rollup Summary using the Trigger, you need to follow below:

Need to consider all DML operations like insert, update, delete and undelete of child records.

Insert of Child record:
     --> Need to write an after insert trigger to update the Parent record with calculated sum value.
Update of Child record:
     --> Make sure that the Parent information got changed.
     --> Need to write an after update trigger and get both old and new Parent information and perform the re-calculation of sum.
Delete of Child record:
     --> Need to write an after delete trigger to update the Parent record with re-calculated sum value.
Undelete of Child record:
     --> Need to write an after undelete trigger to update the Parent record with re-calculated sum value.

Please let me know if it helps you.

Regards,
Mahesh