Monday, August 13, 2012

Set the Default Time in Date type Attribute.

Introduction
                   Today i am going to show you the javascript of set the time in Date Field.Some times back i have requirement of set the time 7:00 when i select any Date From Date Field.If you check then if you select any date the time 00:00 show you.but i have reqirement that i have to set default time value 7:00 when i select the date.and that should only happen when you creating new record.so you have to call the Function in Onchange Event of date Field and use of the FormType for only call it on Create.


function SetDefaultTimeValue()
{
var FORM_TYPE_CREATE = 1;

var formType = Xrm.Page.ui.getFormType();
if (formType == FORM_TYPE_CREATE)
{
var att = Xrm.Page.getAttribute('new_setnextcall');//new_setnextcall is Field name
var curDate = att.getValue();
curDate.setHours(7,0,0);
att.setValue(curDate);
}
}

Now create a new record where this function and field is then and select any date you will see output like


No comments:

Post a Comment