You need to sign in to do that
Don't have an account?
Admin 123
Account and Contact Object have Lookup relationship.
Account and Contact Object have Lookup relationship.
There are two requirements:
To display the count of Contacts into the Account Object.So I have created the trigger for it and now it is displaying the Contacts Count onto the custom field of Account Object.
Now the Second Requirement is: ParentAcc: ABC ,,,Account1: Contact1, Contact2 (count will display 2 in Account custom field) ParentAcc: ABC,,,Account2: Contact1, Contact2, Contact3(count will display 3 in Account custom field)
But now In Parent Account: ABC Count Should Display as 5.
How can we achieve this??
There are two requirements:
To display the count of Contacts into the Account Object.So I have created the trigger for it and now it is displaying the Contacts Count onto the custom field of Account Object.
Now the Second Requirement is: ParentAcc: ABC ,,,Account1: Contact1, Contact2 (count will display 2 in Account custom field) ParentAcc: ABC,,,Account2: Contact1, Contact2, Contact3(count will display 3 in Account custom field)
But now In Parent Account: ABC Count Should Display as 5.
How can we achieve this??
In your trigger make a set of all parent Id field and then query the child based on that and use the parentId field to make a group of them. Now in a map increase the count. Here AccountIdSet is the Id of all parent Account of current child account. Now using this code in the account map you will get a count of all child till 5 level. To fill AccountIdSet you can use the same query.
Hope this helps.
Thanks,
Nagendra