Sunday, 10 May 2009

Calculate Opportunity Age with Jscript

from here: http://blogs.msdn.com/dynamicscrmonline/archive/2008/12/08/calculate-opportunity-age-with-jscript.aspx


Ever wonder how old that opportunity it is. Here's some script that will display a the age of an opportunity when you open it.

Make sure you put the createdon attribute on the form somewhere( admin tab seems the place).

Put the script in the OnLoad

var createdon= crmForm.all.createdon.DataValue;

var today = new Date();

//Set the two dates

today=new Date();

//Set 1 day in milliseconds

var one_day=1000*60*60*24;

//Calculate difference btw the two dates, and convert to days

var Age = Math.ceil((today.getTime()-createdon.getTime())/(one_day));

// Display Age

alert("Opportunity Age in Days : " + Age);

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home