First add the function to a global jscript library
function SetDateTimeInterval(voDateTimeField, viInterval)
{
try
{
//Check the existence of the datetime field. It may not be included in a quick create form!
if (voDateTimeField != null)
{
if (voDateTimeField.getFormat() == "datetime")
{
//The new interval in minutes.
var lsInterval = viInterval;
var loTables = document.getElementById("scheduledstart").getElementsByTagName("table");
if ((loTables != null) && (loTables.length > 0))
{
var loTable = loTables[1];
//Remove all existing values from the selection box while (table.firstChild != null)
{
loTable.removeChild(loTable.firstChild);
}
//Add the new values
for (hour = 0; hour < 24; hour++)
{
for (min = 0; min < 60; min += lsInterval)
{
var row = loTable.insertRow();
var cell = row.insertCell();
var time = ((hour < 10) ? "0" : "") + hour + ":" + ((min < 10) ? "0" : "") + min;
cell.setAttribute("val", time);
cell.innerText = time;
}
}
}
}
}
}
catch (e)
{
CatchErrorMessage(e);
}
}
Call the function from a local jscript library e.g. appointment
function SetDateTimeIntervalTo15Min(){
try
{
var lsFieldStartTime = "scheduledstart";
var loFieldStartTime = Xrm.Page.getAttribute(lsFieldStartTime);
//Set Interval to 15 minutes
var liInterval = 15;
if (loFieldStartTime != null)
{
SetDateTimeInterval(loFieldStartTime, liInterval);
}
}
catch (e)
{
CatchErrorMessage(e);
}
}
As you said add the function in"GLOBAL JSCRIPT LIBRARY " Where I find GLOBAL JSCRIPT LIBRARY or need to Create new one as we create new web resource in CRM
ReplyDelete