7

I ran into a similar issue for a project that I was on last year in which I was dealing with managing the blocks of IP Addresses that my company controls. In my case, the hierarchy could be up to 17 levels deep (with some 2^16 possible records indirectly related to a single block of IP Addresses). You really have 2 issues to tackle in this question: How do ...


7

trigger updatechildwithparent on child__c (before insert) { // Get a list of all Parent Ids Set<Id> parentIds = new Set<Id>(); for (child__c chld : trigger.new) { parentIds.add(chld.MyParent__c); } // Get a map of all Parents with field information Map<Id, Parent__c> parentsById = new Map<Id, Parent__c>(); ...


6

You can determine the ultimate parent in the hierarchy with this easy formula on the account object: IF(LEN(Parent.Name) < 1, HYPERLINK("/"&Id, Name,"_parent"), IF(LEN(Parent.Parent.Name) <1, HYPERLINK("/"&Parent.Id,Parent.Name,"_parent"), IF(LEN(Parent.Parent.Parent.Name) < 1, HYPERLINK("/"&Parent.Parent.Id,Parent.Parent.Name,"...


5

Unfortunately querying hierarchies can be kind of a pain, and you're current approach scales linearly with the hierarchy size, which means assuming no other code is sharing your limits, you can deal with a max hierarchy size of 100. You'll need to re-architect this method to remove the recursion for the query portion. The basic approach is to query to ...


4

If you try to pursue this to a more limited depth, you can greatly reduce your compile size. If you ever get to a hierarchy depth of 500 records, anything you implement will probably crash and burn, this approach included. If you expect any hierarchy to hit such depth, you should seriously reconsider your architecture. Ultimate_Parent__c BLANKVALUE(Parent....


4

The hierarchy can be as big as you like, I think your issue is related to the display of the hierarchy somewhere? All accounts have a parent account field which is a lookup field, you can chain all the accounts in your org should you want to, but a limit you will hit is the number of relationships you can traverse in SOQL queries and formula fields. You can ...


4

I've only done this for immediate children (admittedly for separate parent/child SObjects - see Dmitriy's comment), but assume this trigger approach will work: trigger AreaTrigger on Area__c (before delete) { Set<Id> ids = Trigger.oldMap.keySet(); delete [ select Id from Area__c where Parent__c in :ids or ...


4

Your code will not work until you actually configure the custom setting. Navigate to Setup > Develop > Custom Settings. Click the New button. Populate the Label, for example Hierarchy Setting. Populate the Object Name, for example HierarchySetting. Leave the Setting Type as Hierarchy (default). Click the Save button. Once you follow the above steps, you ...


4

A simple SOQL will work here. SELECT UserName, Id, Manager.Name, Manager.Id, Manager.Profile.Name FROM User if it's a new custom field you can refer the same.


3

On question 1), an alternative to the ultimate parent approach is a query per layer: Id accountId = '...'; Account[] allChildren = new Account[] {}; Set<Id> parentIds = new Set<Id>{accountId}; Account[] children; do { children = [select Id, Name from Account where ParentId in :parentIds]; allChildren.addAll(children); parentIds.clear(...


3

The key to any such functionality is an Ultimate_Parent__c function. I think it maxes out at ten levels deep, but here is a smaller example of how it should work: BLANKVALUE(Parent.Parent.ParentId, BLANKVALUE(Parent.ParentId, BLANKVALUE(ParentId, Id ))) Then, given any account, you can find its entire hierarchy using: SELECT Id FROM Account ...


3

I'm not saying this will solve your problem as I can tell you are holding back underlying complexities but it is an alternative to Test.loadData where you need a lot of control over your other-unmockable-by-DML test data. Production class public class MyProdClass { public interface IUltimateAccount { Account get(); } public class ProdUltimateAccount ...


3

Not all reports filter on the role hierarchy. Those that do support filtering by hierarchy will automatically provide this option when saving the report using Save or Save As. Those that do not cannot be customized to do so.


3

You cannot compare a field to another field in SOQL. The standard workaround is to use a formula. It's hard to tell what you're trying to achieve based on your syntax, but if you wanted to filter on records where one field equals another, you would do make a formula (say DoesField1EqualField2__c) that looks like: Field1__c = Field2__c And then in your ...


3

I think you'll be able to implement this requirement without any Apex. Instead you should be able to use Process Builder to retrieve and set this field. Create a new Process Builder flow. The process starts when: a record changes. Add Object: User. Start the process: when a record is created or edited. Add Criteria named something like "Manager Changed". ...


3

You can update the parent with a child update. I actually built this out as a test to confirm that it does work. You just need to make sure your criteria are correct. This even works recursively if the records are in a hierarchy.


2

support.activision.com/ This site is on force.com and uses knowledge base.You can browse through each article to see how they are organised. The requirement can be achieved since knowledge articles support html.With html content you can organise. For having different template based on article type you can use articles inside visualforce.So depending on ...


2

To borrow a consulting cop-out, I think the answer depends on your business processes and objectives. Girbot made a great recommendation to engage the business in conversation on this topic. Or, put in other words, please consider your organization's unique context. With that said, let's explore (thinking out loud) a few business considerations, and then ...


2

This aggregate query will produce a map where the key is the ID of the project and the value is the number of matching project board objects: Map<Id, Integer> m = new Map<Id, Integer>(); for (AggregateResult ar : [ select Project__c p, count(Id) c from Project_Board__c where Project_Firm__c != null and Project__c ...


2

You could try it write it yourself. Would be a two step process: First you have to fetch the data from the database into a appropriate data-structure. Second you have to visualize it Fetch data An first approach would be to start with a given account C upstream querying for parents. Querying one level at a time is usually trivial. You could repeat it by ...


2

This functionality is available on Sales (opportunities), forecast and activities based reporting only.


2

Eric is right, you will hit the governor limit in whatever way you try to achieve through Apex. However there is a Workaround for this. If your Goal is just to get the Grand Parent, then do this: Create a new custom field called GrandParent__c on Account object. Through trigger(or anything else) update this field by the Name of the Account in lookup. If ...


2

Use this code: //======================================= Group groupListRS = [SELECT id,name,Type,DeveloperName,relatedid FROM Group where Type='Role' AND DeveloperName ='CEOA']; Set<id> allSubRoleIds = new set<id>(); allSubRoleIds = getAllSubRoleIds(new Set<ID>{groupListRS.relatedId}); public Set<ID> getAllSubRoleIds(Set<ID&...


2

You cannot create master-detail relationship when referencing the same object. You could create lookup to the same Territory Custom object. Just think about how Salesforce default Account Hierarchy works. It has default parent Account lookup field to itself. Refer Object Relationships Overview Lookup Links two objects together. Lookup relationships are ...


2

Have a look at the lightning:tree base component. The example given there basically illustrates your use case. All you need to do is implement an Apex controller to query the UserRole object and build the hierarchy and transform it to JSON in the Java Script controller. Lightning Component <aura:component> <aura:handler name="init" ...


2

Besides lightning:tree component there is lightning:treeGrid one. There are small diffrences in implementation but I think that treeGrid just looks better. Component <aura:component> <aura:handler name="init" value="{!this}" action="{!c.init}" /> <aura:attribute name="gridColumns" type="List" /> <aura:attribute name="gridData" type="...


2

I also wanted to create a Lightning component that would indicate if the account was a part of a hierarchy (had a parent or children), and if so, link to the account hierarchy page. Here's how I was able to link to the Lightning experience version of the account hierarchy page in a Lightning component: AccountHierarchy.cmp (Component): <aura:component ...


2

To create multiple hierarchical custom settings for multiple profiles for use in Unit tests... insert new List<ConcurrentSessionsPolicyLimit__c> { new ConcurrentSessionsPolicyLimit__c( SetupOwnerId = [SELECT id FROM Profile WHERE Name = 'profileA'][0].Id, Login_Attempts_Limit__c = someVal), new ConcurrentSessionsPolicyLimit__c( ...


1

try, [SELECT Id from account where child_accountId = :parent_account]; Since both child account Id and Parent_account are on account object, you can compare. parent_account is a variable that holds parent account Id. It will be assigned as follows, string parent_account = account.accountId;


1

I believe your only option if you want to support multiple domains is an org split. It doesn't seem like a feature they can easily relax the limit on. You can use Salesforce2Salesforce if you need to sync data between the orgs. An org split might be a bit heavy-handed, depending on your end goal. It's still unclear what you're actually trying to accomplish....


Only top voted, non community-wiki answers of a minimum length are eligible