Welcome to MSDN Blogs Sign in | Join | Help

Microsoft Dynamics CRM Online Team Blog

This blog is focused on Microsoft Dynamics CRM Online (crm.dynamics.com).

News

  • The views expressed in this blog are those of the individual and do not necessarily represent those of Microsoft. This information is provided by way of general information only and should not be relied on without obtaining independent expert advice. These postings are provided "AS IS" with no warranties and confer no rights. You assume all risk for your use.
Calculate Opportunity Age with Jscript

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);

-cheers
Jon

Posted: Monday, December 08, 2008 11:21 AM by JonWhite

Comments

Microsoft Dynamics CRM Online Team Blog said:

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

# December 8, 2008 4:43 PM
Anonymous comments are disabled
Page view tracker