locked
Xrm.Utility.confirmDialog bug or feature ? RRS feed

  • Question

  • In SDK 2013 and online there’s a note regarding usage of blocking modal windows and mobile devices:

       "If you use window.alert in your form scripts the message you set will automatically be displayed using Xrm.Utility.alertDialog without a callback function specified, but this is temporary and    

         is already considered deprecated. You should move any code using window.alert to use Xrm.Utility.alertDialog instead".

    I moved my SDK xrmForm.Confirm utility which underneath used window.confirm to Xrm.Utility.confirmDialog to support none blocking devices only to find that the confirmDialog does not return a value (true or false) when browsed from a web application. The confirmDialog does use a regular blocking confirm but the function does not return anything (see first Confirm method in my code sample) . This forced me to check if the client is a mobile device myself and use window.confirm if it’s not.  (see second confirm method in my code sample)

    Using the second Confirm method is in contrast to MS statement, So the question is: Do we need to test for mobile ourselves or should we expect the function to do that for us (BUG)?

    function XrmForm() {
        var xfrm = this;
        
        //First Confirm returns undefined
        xfrm.Confirm (message, onOk , onCancel) {
            return Xrm.Utility.confirmDialog(message,onOk, onCancel);
        }
    
        //Second Confirm
        xfrm.Confirm (message, onOk, onCancel) {
            var result;
            if (xfrm.IsMobile())
                Xrm.Utility.confirmDialog(message,onOk, onCancel);
            else
                result = window.confirm(message);
            return result;
        }
        
        xfrm.IsMobile = function() {
            return context.client.getClient() === "Mobile";
        }
    }
    

    Cheers,

    Adi


    Dynamics CRM - Thinking outside the Box

    Saturday, August 9, 2014 9:29 PM