How to build a basic Gantt chart in Salesforce.com

This video outlines one possible simple, easily-appplied technique to display a basic Gantt-style timeline for a project, right in its own related list of Tasks or Milestones. It’s not sophisticated; it doesn’t allow the user to reschedule with drag-and-drop or anything fancy like that, but it doesn’t take long to set up and it doesn’t take any skills beyond those of a Salesforce Administrator to achieve. Also, this will work equally well with Professional Edition and above, without any need to get your hands on any VisualForce or Apex. Nothing but good, clean formula fields…

As promised in the video itself, here is the formula field code, to save you trying to pause the video and type it all out. It will need to be tweaked to work on your own org, of course; the image URLs won’t work, and your field and object names will probably be different. But it ought to be easy enough to get it working, and it’s a useful starting point, anyway:

/* Spacer Image URL:
/servlet/servlet.ImageServer?id=0154K000000PrTn&oid=00D4K000001njZ0
Grey image URL:
/servlet/servlet.ImageServer?id=0154K000000PrzW&oid=00D4K000001njZ0
Project Length / Days:
Project__r.Latest_Task_End__c-Project__r.Earliest_Task_Start__c
Gap before Start Date / Days:
Start_Date__c-Project__r.Earliest_Task_Start__c
Length of Project Task / Days:
(End_Date__c-Start_Date__c)+1
Gap after Task End / Days:
Project__r.Latest_Task_End__c-End_Date__c */

/* Spacer before start of Project Task: */
IMAGE("/servlet/servlet.ImageServer?id=0154K000000PrTn&oid=00D4K000001njZ0",
"Spacer",
13,
(Start_Date__c-Project__r.Earliest_Task_Start__c)*250/(Project__r.Latest_Task_End__c-Project__r.Earliest_Task_Start__c)
)
&
/* Project Task: */
HYPERLINK("/"&Id,
IMAGE(CASE(Status__c,"Planned","/img/samples/color_green.gif", "In Progress", "/img/samples/color_yellow.gif", "/img/samples/color_red.gif"),
"Task",
13,
((End_Date__c-Start_Date__c)+1)*250*if( Percent_Complete__c =0 || Percent_Complete__c=1,1,Percent_Complete__c)/(Project__r.Latest_Task_End__c-Project__r.Earliest_Task_Start__c)
)&
IMAGE("/servlet/servlet.ImageServer?id=0154K000000PrzW&oid=00D4K000001njZ0",
"Task",
13,
((End_Date__c-Start_Date__c)+1)*250*if( Percent_Complete__c =0 || Percent_Complete__c=1,0,1-Percent_Complete__c)/(Project__r.Latest_Task_End__c-Project__r.Earliest_Task_Start__c)
),
"_self")
&
/* Spacer after end of Project Task: */
IMAGE("/servlet/servlet.ImageServer?id=0154K000000PrTn&oid=00D4K000001njZ0",
"Spacer",
13,
(Project__r.Latest_Task_End__c-End_Date__c)*250/(Project__r.Latest_Task_End__c-Project__r.Earliest_Task_Start__c)
)

Leave a Reply