TransWikia.com

How to get value on a custom field of child account as account name of parent of parent account?

Salesforce Asked by SFDC devloper on December 7, 2021

Suppose, I have a child account as "Child Account" and it’s parent account as "Parent Account" then there is one more parent account of parent account which named as " Parent of Parent Account" of child.

So, the relationship will be like:
Child Account-> Parent Account-> Parent of Parent Account.

Now, I have one custom field "Corporate" on child account to be populated with the name of "Parent of Parent" Account.

Can anyone suggest the best way to populate the value of child account from parent of parent account of that child?

One Answer

Similar to the comment on your question from zaitsman, use a formula. The formula will want to protect itself based on whether there are multiple levels, something like:

IF(NOT(ISBLANK(ParentId)),
    IF(NOT(ISBLANK(Parent.ParentId)),
        Parent.Parent.Name,
        Parent.Name),
    Name)

If I got the brackets right, the idea is to take the grandparent name if available. If there is no grandparent but there is a parent, take that name and if there is no parent use the account's own name.

Answered by Phil W on December 7, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP