Wednesday, September 18, 2024

Day 4 - Validating Form Fields using JavaScript

Introduction:


In this blog we will see how to Validating Form Fields using JavaScript


function validateDateField(executionContext) {
    var formContext = executionContext.getFormContext();

    if (formContext.getAttribute("bosch_destinationdate").getValue() != null &&
        formContext.getAttribute("bosch_sourcedate").getValue() != null) {

        if (formContext.getAttribute("bosch_destinationdate").getValue() < formContext.getAttribute("bosch_sourcedate").getValue()) {
            var alertStrings = { confirmButtonLabel: "Yes", text: "Destination Date Should be Greater", title: "Date Alert" };
            var alertOptions = { height: 120, width: 260 };
            Xrm.Navigation.openAlertDialog(alertStrings, alertOptions).then(
                function (success) {
                    console.log("Alert dialog closed");
                },
                function (error) {
                    console.log(error.message);
                }
            );
        }
    }
}



No comments:

Post a Comment

Day 5 - Show and Hide fields Based on Condition using JavaScript in MSCRM/Datave

  Introduction: In this blog we will see how to Show and Hide Fields based on Condition using JavaScript in MSCRM/ Dataverse Script: functio...