Display Time picklist in Dynamics Crm 4.0

Here I am putting the javascript code for display the Time Dropdown/Picklist on form.

I will attacheed the screens later

//code inserted here by ali usman dec 5 to have the time in 1 minute interval
SetDateTime = function (dateField)
{
//Check the existence of the datetime field. It may not be included in a quick create form!
if (dateField != null)
{
var timeField = dateField.all.time;
//Check the existence of the time field. It is null if the control is setup to only display the date.
if (timeField != null)
{
//The new interval in minutes.
var interval = 1;
var tables = timeField.getElementsByTagName(“table”);
if ((tables != null) && (tables.length > 0))
{
var table = tables[1];
//Remove all existing values from the selection box while (table.firstChild != null)
{
table.removeChild(table.firstChild);
}
//Add the new values
for (hour = 0; hour < 24; hour++)
{
for (min = 0; min < 60; min += interval)
{
var row = table.insertRow();
var cell = row.insertCell();
var time = ((hour < 10) ? "0" : "") + hour + ":" + ((min < 10) ? "0" : "") + min;
cell.setAttribute("val", time);
cell.innerText = time;
}
}
}
}
}
}
//Changing the time interval in date/time fields
//The time selection box of a date/time field uses a 30 minute interval. You can change it to a different
//interval using the following code in an OnLoad event:

var occurenceDateTimeField = crmForm.all.new_occurencedateandtime;

SetDateTime(occurenceDateTimeField);

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.