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.

Get User Privilege on a field – Dynamics 365 CE

Hi Everyone,

Today I got a requirement to check whether the user has access to read the data on the field where feild level security has been enabled and do some operations.

We can achieve this using getUserPrivilege() client API.

var fieldPrivileges = formContext.getAttribute("new_fieldsecurityfield").getUserPrivilege();

Result when user doesn’t have permission.

Result when user have permission.

Hope this helps.


Happy 365’ing
Gopinath.