Order form has two fields, Ship Date (datefield) and Lead Time (number field in days).
When a ship date is entered, it should be greater than the current date + the lead time. alert user if not, and do not allow save of record.
* There is one exception to the rule though: If the approved for rush field and approved by field is filled out the alert is not necessary and record can be saved.
++ It would be a plus if this could actually not account for weekend days. But not mandatory
function checkLeadTime
{
var shipDate = Xrm.Page.getAttribute("requestdeliveryby").getValue();
var leadTime = Xrm.Page.getAttribute("orbus_leadtime").getValue();
var leadTimeDate = Xrm.Page.getAttribute("orbus_leadtimedate").getValue():
if(leadTime != NULL)
{
var approvedRushProduction = xrm.getAttribute("orbus_projectapprovedrush").getValue();
var approvedBy = Xrm.Page.getAttribute("orbus_approvedbyid").getValue();
var currentTime = new Date();
var newDate = currentTime.setDays(currentTime.getDays + leadTime);
leadTimeDate.setValue(newDate);
if(approvedRushProduction == 0 && approvedBy == NULL)
{
if ( newDate < shipDate)
{
alert("Sorry, Ship Date is less than lead time!");
}
else
{
alert("Current Time = " + newDate);
}
}
}
}