[SalesForce] Duplicating Opportunity Stage Duration for Custom Field

It's probably been asked before, but how do you duplicate the Stage Duration functionality in Opportunities on a custom field? I have a custom picklist field named "Operations Status" that serves the same purpose as the Opportunity Stage field. Users select a value that changes based on events driving our operations process. The statuses do not move in a linear fashion and can go back-and-forth based on certain events so a record can go from Value1 to Value2 to Value3 and back to Value2.

The idea is to track the duration on each status value and account for the back-and-forth situations (probably incorporating some sort of counter?) as well as the dates they occurred.

Does this involve the creation of n custom fields where n = the number of Status values or is this something that warrants it's own Custom object related to the parent object which is Opportunity in this case? Additionally, does this require the use of Apex Triggers or can this be done using declarative configuration (Workflows, Formulas, and such)?

Thank you in advance for the feedback.

Sean

Best Answer

Depending on your requirements, I can see two solutions here:


Solution 1

You can turn on history tracking for the Stage on the opportunity. This will track every time it has change, by who, and when. You can an opportunity history report (this is out of the box) which will give you the individual entries. Look at this help article: http://help.salesforce.com/HTViewHelpDoc?id=reports_opp_history.htm&language=en_US


Solution 2

As some of the previous comments imply - create a custom object that is a child of the Opportunity (Call it OpportunityStageEvents for arguments sake). Here is how it would work:

  1. Create the new object and the fields you want to retain (like from and to stage names, time spent in this duration, who made the change, etc.)
  2. Make the new custom object as a child of opportunity (by using master-detail relationship on the custom object to the opportunity)
  3. Next you need to trigger every time you change the stage to create a record and capture the information. There are two ways to do this: a) create an Apex trigger to get the values, create the new child object record and insert it b) use the new process builder to essentially do the same thing (my preference - and a very powerful tool - but still in beta)

Happy to provide more details if required.