Show a break in Dynamics 365 CE alerts – JavaScript

Hi Everyone,

Today I was writing a JavaScript to some alert message to the user. To fulfill my requirement, I have to show two messages in the same box and I have written the code as below.

 var alertStrings = { confirmButtonLabel: "Ok", text: "Line 1\n Line 2", title: "Sample title" };
    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);
        }
    );

Somehow, I felt that the message was not looking good and it would look better if give the space between message and after some search came to know that it works if we write the code as below.

var alertStrings = { confirmButtonLabel: "Ok", text: "Line 1 \n" + decodeURI("%E2%80%8A") + "\nLine 2", title: "Sample title" };
    var alertOptions = { height: 250, width: 260 };
    Xrm.Navigation.openAlertDialog(alertStrings, alertOptions).then(
        function (success) {
            console.log("Alert dialog closed");
        },
        function (error) {
            console.log(error.message);
        }
    );

Hope this helps.


Happy 365íng
Gopinath.

Enable/Disable the field placed in multiple places on the form

Hi Everyone,

Today I was writing JavaScript code to disable the field on some condition and observed that the field is not getting disabled. I was little surprised and tried with some other field and it worked perfectly. By this, I understand that there is some problem with this field and after some search understood that the same field has been placed on other tabs as well.

To fix it, we just have apply loop through the control. Here is the sample code for the same.

formContext.getAttribute("SchemaName").controls.forEach(
function (control, i) {
control.setDisabled(true);
});

Hope this helps.


Happy 365’ing
Gopinath.