Skip to content

Instantly share code, notes, and snippets.

@Walletau
Walletau / mps5.cls
Created March 29, 2017 16:50
MagicParentsSnippet5
Account a = [SELECT Id, Name,
Owner.Manager.Manager.ManagerId
FROM Account
WHERE Id = '001p000000K12dV' LIMIT 1];
System.debug('1: ' + a.OwnerId);
System.debug('2: ' + a.Owner.ManagerId);
System.debug('3: ' + a.Owner.Manager.Manager.Manager.Manager.FirstName);
System.debug('3: ' + a.Owner.Manager.LastName);
@Walletau
Walletau / mps4.cls
Created March 29, 2017 16:49
MagicParentsSnippet4
Account a = [SELECT Id, Name,
Parent.Parent.Parent.ParentId
FROM Account
WHERE Id = '001p000000K12dV' LIMIT 1];
@Walletau
Walletau / mps3.cls
Created March 29, 2017 16:48
MagicParentsSnippet3
Account a = [SELECT Id, Name,
ParentID,
Parent.ParentId
FROM Account
WHERE Id = '001p000000K12dV' LIMIT 1];
@Walletau
Walletau / mps2.cls
Created March 29, 2017 16:45
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);
@Walletau
Walletau / mps1.cls
Last active March 29, 2017 16:28
MagicParentsSnippet1
public static Set<Id> getTopAccountIds(Set<Id> accountsTargeted) {
Set<Id> topAccountIds = new Set<Id>();
Set<Id> recursivelyTargetedAccountIds = new Set<Id>();
for (Account targetedAccount : [
SELECT Id,
Name,
ChildrenUserGroupId__c,
ChildrenIncludedUserGroupId__c,
UserGroupId__c,
ParentUserGroupId__c,
public static Set<Id> getTopAccountIds(Set<Id> accountsTargeted) {
Set<Id> topAccountIds = new Set<Id>();
Set<Id> recursivelyTargetedAccountIds = new Set<Id>();
for (Account targetedAccount : [
SELECT Id,
Name,
ChildrenUserGroupId__c,
ChildrenIncludedUserGroupId__c,
UserGroupId__c,
ParentUserGroupId__c,
/**
* Created by Nick Likane on 30/12/2016.
*/
public without sharing class SecurityUtil {
// Default up down map
public static Boolean GroupCalculationActive = false;
//////////
//Managing of specific share records
//////////