Created
October 12, 2022 05:50
-
-
Save Sunil02kumar/f017c233074fd7d3d1a20d1129e753fc to your computer and use it in GitHub Desktop.
Formula Field to Ultimate Account Id in Account Hierarcy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IF(ISBLANK(ParentId), Id, | |
IF( | |
/* Parent Level 10 */ | |
NOT(ISBLANK(Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.ParentId)) | |
,Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Id | |
,IF( | |
/* Parent Level 9 */ | |
NOT(ISBLANK(Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.ParentId)) | |
,Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Id | |
,IF( | |
/* Parent Level 8 */ | |
NOT(ISBLANK(Parent.Parent.Parent.Parent.Parent.Parent.Parent.ParentId)) | |
,Parent.Parent.Parent.Parent.Parent.Parent.Parent.Id | |
,IF( | |
/* Parent Level 7 */ | |
NOT(ISBLANK(Parent.Parent.Parent.Parent.Parent.Parent.ParentId)) | |
,Parent.Parent.Parent.Parent.Parent.Parent.Id | |
,IF( | |
/* Parent Level 6 */ | |
NOT(ISBLANK(Parent.Parent.Parent.Parent.Parent.ParentId)) | |
,Parent.Parent.Parent.Parent.Parent.Id | |
,IF( | |
/* Parent Level 5 */ | |
NOT(ISBLANK(Parent.Parent.Parent.Parent.ParentId)) | |
,Parent.Parent.Parent.Parent.Parent.Id | |
,IF( | |
/* Parent Level 4 */ | |
NOT(ISBLANK(Parent.Parent.Parent.ParentId)) | |
,Parent.Parent.Parent.Parent.Id | |
,IF( | |
/* Parent Level 3 */ | |
NOT(ISBLANK(Parent.Parent.ParentId)) | |
,Parent.Parent.Parent.Id | |
,IF( | |
/* Parent Level 2 */ | |
NOT(ISBLANK(Parent.ParentId)) | |
,Parent.Parent.Id | |
,IF( | |
/* Parent Level 1 */ | |
NOT(ISBLANK(ParentId)) | |
,Parent.Id | |
,NULL | |
) | |
) | |
) | |
) | |
) | |
) | |
) | |
) | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment