Recently
our client has came with the requirement that, they don’t want to allow a future
date selection for a particular field on Microsoft Dynamics CRM form.
Well, it
is not a complex task to implement. Here is the sample code for it-
function restrictFutureDate() {
    if (Xrm.Page.getControl("Date_Field")) {
        var getfieldValue = Xrm.Page.getAttribute("Date_Field").getValue();
        var today = new Date();
        if (getfieldValue > today) {
            Xrm.Page.getControl("Date_Field").setNotification("Future date is not allowed!", "DATEERROR");
        } else {
            Xrm.Page.getControl("Date_Field").clearNotification("DATEERROR");
        }
    }
}
No comments:
Post a Comment