Skip to content

Instantly share code, notes, and snippets.

@Walletau
Created March 29, 2017 16:45
Show Gist options
  • Save Walletau/f7aa2ad53a774292fbff671b40d963be to your computer and use it in GitHub Desktop.
Save Walletau/f7aa2ad53a774292fbff671b40d963be to your computer and use it in GitHub Desktop.
MagicParentsSnippet2
Account a = [SELECT Id, Name,
ParentID,
Parent.ParentId,
Parent.Parent.ParentId
FROM Account
WHERE Id = '0013600000NHSlW' LIMIT 1];
System.debug('1: ' + a.ParentId);
System.debug('2: ' + a.Parent.ParentId);
System.debug('3: ' + a.Parent.Parent.ParentId);
System.debug('4: ' + a.Parent.Parent.Parent.ParentId);
System.debug('5: ' + a.Parent.Parent.Parent.Parent.ParentId);
System.debug('6: ' + a.Parent.Parent.Parent.Parent.Parent.ParentId);
System.debug('7: ' + a.Parent.Parent.Parent.Parent.Parent.Parent.ParentId);
System.debug('8: ' + a.Parent.Parent.Parent.Parent.Parent.Parent.Parent.ParentId);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment