THis script will set the default date of a form, this script is important because it sets the default date only for the Create form and not the update form. Otherwise the onload event will always set the date to the current date, even if its been updated. Credit to Sonomoa Partners.
var CRM_FORM_TYPE_CREATE = 1;
var CRM_FORM_TYPE_UPDATE = 2;
switch (crmForm.FormType)
{
case CRM_FORM_TYPE_CREATE:
crmForm.all.new_openddate.DataValue = new Date();
break;
case CRM_FORM_TYPE_UPDATE:
// do nothing
break;
}
