Setting the Default Date of a form to the current date with Record Creation

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

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>