APPBUDDY BLOG

REQUEST A DEMO

Create Breadcrumb with a Formula Field

Posted by Kelly Lam on May 8, 2015 9:26:00 AM | Share

Have you ever gotten lost in the Account hierarchy? With a formula field, you can create a breadcrumb to keep track of where you are. 

It will look something like this: Acme Parent account > Acme Account > Acme Sub Account 

To achieve this, we're going to do the following steps:

  1. Create a formula field for Account hierarchy level
  2. Create the breadcumb formula field
  3. Create formula field for the "Drill Up" action
  4. Add the breadcumb formula field to the grid of Accounts
  5. Create an action to drill down 1 level in the hierarchy
  6. Create an action to drill up 1 level in the hierarchy
  7. Add the actions to the grid

 

Step 1: Create a formula field for Account hierarchy level

First, we'll need a new text formula field called "Hierarchy Level" on the Account object. Copy the code below into the formula editor: 

IF(!ISBLANK(ParentId), 2, 1)+

IF(AND(!ISBLANK(ParentId),!ISBLANK(Parent.ParentId)), 1, 0)+

IF(AND(!ISBLANK(ParentId), !ISBLANK(Parent.ParentId), !ISBLANK(Parent.Parent.ParentId )),1, 0)+

IF(AND(!ISBLANK(ParentId), !ISBLANK(Parent.ParentId), !ISBLANK(Parent.Parent.ParentId ), !ISBLANK(Parent.Parent.Parent.ParentId)), 1, 0)+

IF(AND(!ISBLANK(ParentId), !ISBLANK(Parent.ParentId), !ISBLANK(Parent.Parent.ParentId ), !ISBLANK(Parent.Parent.Parent.ParentId), !ISBLANK(Parent.Parent.Parent.Parent.ParentId)), 1, 0)+

IF(AND(!ISBLANK(ParentId), !ISBLANK(Parent.ParentId), !ISBLANK(Parent.Parent.ParentId), !ISBLANK(Parent.Parent.Parent.ParentId), !ISBLANK(Parent.Parent.Parent.Parent.ParentId), !ISBLANK(Parent.Parent.Parent.Parent.Parent.ParentId)), 1, 0)

 

Step 2: Create the breadcumb formula field

Next, we'll create the field called Hierarchy Link that prints out the breadcrumb links leveraging the Hierarchy Level field we just created. It will be a text type formula field on the Account object just like the previous field. Copy the code below into the formula editor:  

CASE(Hierarchy_Level__c, 
1, "",

2, HYPERLINK("/apex/gblite__Grid?gname=Account+Grid&fpf=ParentId&fpv=" + ParentId, Parent.Name,"_self") + " > ",

3, HYPERLINK("/apex/gblite__Grid?gname=Account+Grid&fpf=ParentId&fpv=" + Parent.ParentId, Parent.Parent.Name,"_self") + " > " +
HYPERLINK("/apex/gblite__Grid?gname=Account+Grid&fpf=ParentId&fpv=" + ParentId, Parent.Name,"_self") + " > ",

HYPERLINK("/apex/gblite__Grid?gname=Account+Grid&fpf=ParentId&fpv=" + Parent.Parent.ParentId, Parent.Parent.Parent.Name,"_self") + " > " +
HYPERLINK("/apex/gblite__Grid?gname=Account+Grid&fpf=ParentId&fpv=" + Parent.ParentId, Parent.Parent.Name,"_self") + " > " +
HYPERLINK("/apex/gblite__Grid?gname=Account+Grid&fpf=ParentId&fpv=" + ParentId, Parent.Name,"_self") + " > ")

+ HYPERLINK("/apex/gblite__Grid?gname=Account+Grid&fpf=ParentId&fpv=" + Id, Name, "_self")

 

Step 3: Create formula field for the "Drill Up" action

Next, we'll create a text formula field called Parent Account URL that prints out the URL that the "Drill Up" action will be using in step 6. Copy the code below into the formula editor:  

'/apex/gblite__grid?gname=Account Grid&fpf=Id&fpv=' + Parent.Id

 

Step4: Add the breadcumb formula field to the grid of Accounts

Create a new grid of Accounts or use an existing one. Go to the 2nd page of the Grid Wizard for that grid, and add the Hierarchy Link field to the grid. 

 

Step 5: Create an action to drill down 1 level in the hierarchy

Go to the Manage Actions page in GridBuddy. You can access it from the Grid Wizard landing page. Create a new action with the below configuration:

 Managing Actions with Salesforce

 

Step 6: Create an action to drill up 1 level in the hierarchy

Still on the Manage Actions page create a new action for drilling down. See example configuration below:

 Managing Actions on Gridbuddy

 

Step 7: Add the actions to the grid 

Go to the 2nd page of the Grid Wizard for the grid from step 3. Scroll down to the bottom of the page to the Select Actions section. Check the checkboxes next to our 2 new actions we created in the last 2 steps: "Drill Down" and "Drill Up".

Save the page and launch the grid. The end result should look something like this:

Account Bredcrums with GridBuddy

 

Want to give GridBuddy a try for yourself and don’t have it installed yet? Install 14-day cost-free/risk-free trial of GridBuddy Unlimited from the AppExchange now!

Try GridBuddy for FREE

 

Subscribe To The AppBuddy Blog

Or Leave A Comment