locked
Javascript alerts are not working [CRM 2013] RRS feed

  • Question

  • Hi,

    I can't get a simple javascript alert to work. I have verified that the function in which I put the alert is running fine (it's setting a value in a text field and I can change it and see correct results). 

    Is there something I am missing here? It's not working in IE11 nor Chrome (latest update).

    This is what it looks like:

     setTemporaryName: function () {
    alert("temp name");
            //get the name (primary field) of the Action
            var name = Xrm.Page.getAttribute("custom_name").getValue();
            if (!name || 0 === name.length) {
                Xrm.Page.getAttribute("custom_name").setValue('TEMP');
            } else {
            }
        },

    The text field is set to "TEMP" (or whatever I change it to) but the alert simply is not popping up. Tried on different computers and different laptops.

    Monday, November 3, 2014 9:46 AM

All replies

  • Hi Simon,

    Please make sure your Pop up blocker is not checked.


    Regards, Saad

    Monday, November 3, 2014 9:54 AM
  • Hi Simon,

    I made some changes in your code, tested and it is working fine:

    function setTemporaryName() {
    
        Xrm.Utility.alertDialog("temp name");
    
        //get the name (primary field) of the Action
        var name = Xrm.Page.getAttribute("field_name").getValue();
    
        if (!name || name.length === 0) {
    
            Xrm.Page.getAttribute("field_name").setValue('TEMP');
    
        }
    }

    Reference: http://thecrmwiz.com/2013/10/22/pop-up-javascript-changes-in-dynamics-crm-2013


    Monday, November 3, 2014 1:50 PM