Monday, October 7, 2024

Day 10 - Using JavaScript to Set Field Requirements Dynamically - JavaScript in MSCRM/Dataverse

 In this Blog, we will see how to Set Field Requirements Dynamically - JavaScript in MSCRM/Dataverse



if (formContext.getAttribute("bosch_booleanfield").getValue() == true) {
        formContext.getAttribute("bosch_enabledisablefield").setRequiredLevel("none");
    }
    else if (formContext.getAttribute("bosch_booleanfield").getValue() == false) {
        formContext.getAttribute("bosch_enabledisablefield").setRequiredLevel("required");
   }

Monday, September 30, 2024

Wednesday, September 25, 2024

Day 7: Formatting Data (Dates, Numbers) in MSCRM JavaScript

In this Blog we will see Formatting Data (Dates, Numbers) in MSCRM JavaScript


if (formContext.getAttribute("bosch_destinationdate").getValue() != null){
var getFullYear = formContext.getAttribute("bosch_destinationdate").getValue().getFullYear();
        var getDate = formContext.getAttribute("bosch_destinationdate").getValue().getDate();
        var getMonth = formContext.getAttribute("bosch_destinationdate").getValue().getMonth() + 1;

        formContext.getAttribute("bosch_getnumbersfromdestinationdate").setValue(getFullYear + "-" + getDate + "-" + getMonth);
}





Monday, September 23, 2024

Day 6: Showing and Hiding Fields with JavaScript in MSCRM

 Introduction :


In this blog we will see how to Showing and Hiding Fields with JavaScript in MSCRM


function enableDisableFieldsBasedonCondition(executionContext) {
    debugger;
    var formContext = executionContext.getFormContext();

    if (formContext.getAttribute("bosch_booleanfield").getValue() == true) {
        formContext.getControl("bosch_enabledisablefield").setDisabled(true);
    }
    else if (formContext.getAttribute("bosch_booleanfield").getValue() == false) {
        formContext.getControl("bosch_enabledisablefield").setDisabled(false);
    }
}













Thursday, September 19, 2024

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:

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

    if (formContext.getAttribute("bosch_booleanfield").getValue() == true) {
        formContext.getControl("bosch_showorhidefield").setVisible(true);
    }
    else if (formContext.getAttribute("bosch_booleanfield").getValue() == false) {
        formContext.getControl("bosch_showorhidefield").setVisible(false);
    }
}

Trigger above code on ONCHANGE.


Attaching my video here for Detail





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);
                }
            );
        }
    }
}



Monday, September 16, 2024

Basic event handling - Onload, Onchange in MSCRM / Dataverse

 Introduction:


Day 3 : Basic event handling - Onload, Onchange in MSCRM / Dataverse


Script :


function onChange(executionContext) { debugger; var formContext = executionContext.getFormContext(); if (formContext.getAttribute("bosch_dayname").getValue() != null) { var alertStrings = { confirmButtonLabel: "Yes", text: formContext.getAttribute("bosch_dayname").getValue(), title: "Throw 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); } ); } }




Day 10 - Using JavaScript to Set Field Requirements Dynamically - JavaScript in MSCRM/Dataverse

  In this Blog, we will see how to Set Field Requirements Dynamically - JavaScript in MSCRM/Dataverse if (formContext.getAttribute( "b...