Let’s create a Calculated Field that calculates the Cycle Time of a Deal.
Note: The App you create this Calculated Field in can vary based on your FreeAgent setup. We are using the Deals App for our example but a Leads or Projects App works just as well.
To begin we will need the following fields in the Deals App:
- Start Date- A Date Field that contains the date the deal record was created.
- Close Date- A Date Field that contains the date the deal record was marked as Closed.
See How to create a new form field for more.
Begin by naming the Calculated Field and selecting what Section of the Deals App the Calculated Field will be displayed in (the choices will depend on your setup).
Next, click the Show Advanced Settings box and change the Calculated field to Yes.
Now, select script Calculation Type. Enter the following code snippet into the Script window:
(function(deal){
var StartDate = Date.parse(deal.created);
var EndDate = Date.parse(deal.closeDate);
if(!EndDate){
return 0;
}
var timeBetween = EndDate - StartDate;
var days = timeBetween / (24 * 60 * 60 * 1000);
var justDays = parseInt(days);
return justDays;
}(deal));