Workaround for Roll-Up field on Account object to count the number of Contacts

Workaround for Roll-Up field on Account object to count the number of Contacts
 

When a New Contact is created: (please note, rollup summary will inherit the FLS of its child object)
 
In Classic:
Go to Setup > Account Object > Create a new field with number as datatype (18 length) (default value 0) > give FLS > Save
 
Create Process Builder:
Setup > Workflow Rules and Approvals > Process Builder > New (Enter the Name and Description.) > The process starts when - select a record changes > Save > Add Object (Contact) > Only when a record is created > Save > Add Criteria (Enter the Criteria Name) > Formula evaluates to true > On the formula field - enter True > Save > Add Action > Action Type - Update Records (Enter the Action Name) > Record to Update > Select a record related to the Contact > Type to filter list field and check for Account ID > Click on Choose > Under 'Set new field values for the records you update,' click Find a field and look for the field we created above and click on it > For the Type - click on Formula > Click on Build a formula > formula is  [Contact].Account.Counter__c + 1 on the formula field > Click Use this Formula > Save > Activate.
 
 
In Lightning:
Go to Gear Icon> Setup > Object Manager > Accounts > Fields and Relationships > Create new field with number as datatype (18 length)(default value 0) > give FLS > Save
 
Create Process Builder:
Click on the gear icon and then on Setup > Workflow Rules & Approvals > Process Builder > New (Enter the Name and Description.) > The process starts when - select a record changes > Save > Add Object (Contact) > Only when a record is created > Save > Add Criteria (Enter the Criteria Name) > Formula evaluates to true > On the formula field - enter True > Save > Add Action > Action Type - Update Records (Enter the Action Name) > Record to Update > Select a record related to the Contact > Type to filter list field and check for Account ID > Click on Choose > Under 'Set new field values for the records you update,' click Find a field and look for the field we created above and click on it > For the Type - click on Formula > Click on Build a formula > formula is  [Contact].Account.Counter__c + 1 on the formula field > Click Use this Formula > Save > Activate.
 
Reference:
https://help.salesforce.com/








 

Comments