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 11 - Customizing Option Sets Dropdown Fields with JavaScript

  In this Blog, we will see how to Customizing Option Sets Dropdown Fields with JavaScript label1 = formContext.getAttribute( "bosch_op...