locked
Question on how to see the contents of data.d from inside visual studio debugger RRS feed

  • Question

  • UPDATE - DEBUGGING PROBLEM SOLVED - I moved "debugger;" to the bottom of the function and can now see everything. 

    As a new CRM 2011 developer, I am trying to debug some JavaScript code containing the ODATA Rest function shown below. I specifically need to "see inside of data.d" am am getting an unexpected result via an alert I set up to show me the data.

    The alert is showing me "[object] [object]", as opposed to the expected value which will always be a GUID. 

    When I run the query manually in my browser I know that the GUID info I am expecting is being retuned as shown below because 5c87c42e-af6e-e511-adaa-000c29d70c71 is returned in the browser. I just need to better understand where it is inside of data.d so that I can access it. 

    My ODATA Query and Parse function is shown below.

    ///NEW ODATA REST CODE
    
    function BingoTypeExecuteQuery() {
    debugger;
        var ODataQuery = "/new_s_bingolicensetypeSet?$select=new_s_bingolicensetypeId&$filter=new_bingolicensetype eq 'R'";
    
        var serverUrl = Xrm.Page.context.getServerUrl();
    
        // Adjust URL for differences between on premise and online 
        if (serverUrl.match(/\/$/)) {
            serverUrl = serverUrl.substring(0, serverUrl.length - 1);
        }
    
        var ODataURL = serverUrl + "/XRMServices/2011/OrganizationData.svc" + ODataQuery;
    
        $.ajax({
            type: "GET",
            contentType: "application/json; charset=utf-8",
            datatype: "json",
            url: ODataURL,
            beforeSend: function (XMLHttpRequest) { XMLHttpRequest.setRequestHeader("Accept", "application/json"); },
            success: function (data, textStatus, XmlHttpRequest) {
                var result_data = data.d;
               alert(result_data);
    
            },
            error: function (XmlHttpRequest, textStatus, errorObject) { alert("OData Execution Error Occurred" + ODataURL); }
        });
    
    }

     I am following the instructions located at http://social.technet.microsoft.com/wiki/contents/articles/3256.how-to-debug-jscript-in-microsoft-dynamics-crm-2011.aspx and once inside Visual Studio, I click F5 to continue after the initial break, but I am unable to see inside of data.d like I could if I was debugging in IE Explorer's F12 debugger when an exception is thrown, by simply hovering my mouse over top of data.d to see its contents. 

    Since no exceptions get thrown, I am having problems using the IE native F12 debugger since it doesn't leave main.asp and go to my javascript.js file due to no exceptions being thrown. 

    Ultimately, what I need to do, once the ODATA REST code runs is I need to be able to see inside of data.d so can gain more insight into where the data I need to access is, in order to modify my alert so that specific GUID data is displayed in the alert instead of [Object] [object].

    The only time, it seems like its possible to look at objects from the javascript is the exact point the debugger; code executes as shown below. 

    Once I hit F5 to step through, all the material in the call stack and locals disappears, and the alert executes showing me [object] [object] which does me no good. 

    Then when I click "OK" on the alert, its done. I still cannot see inside of data.d to figure out where specifically the GUID value is.

     

    I tried changing alert(result_data) to alert(result_data.id) and alert(result_data.name) and alert(result_data.value) but all resulted in the alert displaying "undefined" so I know enough to know that I need to see inside of data.d but can't figure out how. 

    Any advise or suggestions would be extremely appreciated. Thanks in advance!


    • Edited by ACECORP Saturday, October 17, 2015 6:35 PM
    Saturday, October 17, 2015 6:23 PM

Answers

  • UPDATE - DEBUGGING PROBLEM SOLVED - I moved "debugger;" to the bottom of the function and can now see everything. 
    • Marked as answer by ACECORP Saturday, October 17, 2015 6:35 PM
    Saturday, October 17, 2015 6:35 PM