Confusing RESTAPI library is failing (I just need all accounts). Debug or alternative? RRS feed

  • Question

  • The library is called scripts crm common.   I have narrowed it down to the returned function that I believe is failing.  I do not need half of this functionality.

    All I need is to return all Accounts in the CRM in a variable.  How do I do that?  This library is included in an HTML web resource that was initiated by other developers as an include file.

    Below I will show the point of failure that I believe is occurring deep in the library.  I will show the arguments that go in and the function itself.  However I am willing to drop it since as written above, my goal is to just get all the accounts and fill them in a variable in the main html page.   It should be noted that this library was working and suddenly stopped.

    Description of Arguments:
    options: { url: query }
        What would I put here to return all accounts?

    async: I believe this is true as earlier code reads:
        var async = !!fnCallback;

    internalCallback: (a function of its own)
    function (data) {
                    var next = data.__next || null;
                    var results = data.results || data;
                    var response = { 'results': results, 'next': next }

                    if (next) { // enable eage loading
                        response.LoadNext = function (callback) {
                            return performRequest(next, callback);

                    if (async)
                        return response;

    errcallback: will be null

    Defined Function

       var _doRequest = function (options, async, internalCallback, errorCallback) {
            // default settings
            var settings = {
                type: "GET",
                async: async,
                contentType: "application/json; charset=utf-8",
                datatype: "json",
                beforeSend: function (request) {
                    request.setRequestHeader("Accept", "application/json");
                error: function (XmlHttpRequest, textStatus, errorThrown) {
                    if (XmlHttpRequest.responseText != null) {
                        var sMessage = XmlHttpRequest.responseText;
                        var o = $.parseJSON(sMessage);

                        if (DEV_MODE) {
                            openStdDlg(errorUrl, o, "600", "400", true, false, "center:1;");
                        else {
                            openStdDlg(serverUrl + errorUrl, o, "600", "400", true, false, "center:1;");
                        if (errorCallback != null) {
                    } else {
                        alert("Error : " + textStatus + ": " + XmlHttpRequest.statusText);
            options = $.extend(settings, options);

            if (!async) {
                var result = $.ajax(options).responseText;
                var jsonResult = (result) ? JSON.parse(result).d : null;

                return !!internalCallback ? internalCallback(jsonResult) : jsonResult;
            else {
                settings.success = function (data, textStatus, XmlHttpRequest) {


    Tuesday, March 22, 2016 9:32 PM