function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
bakumbakum 

"Unknown runtime error" from query?

Hi,

I'm running a very simple query and getting an "Unknown runtime error" in response.  Never got one of those before.  Anyone know what it's about or how I go about making it stop?

Here's the complete code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Support Times</title>
<!-- Include the Salesforce style sheets -->
<link href="/sCSS/Theme2/en/common.css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" type="text/css" />
<link href="/sCSS/10.0/Theme2/allCustom.css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" type="text/css" />

<style></style>

<!-- Get the AJAX Toolkit -->
<script language="JavaScript1.2" src="/js/functions.js"></script>
<script src="/soap/ajax/11.1/connection.js" type="text/javascript"></script>

<script id="clientEventHandlersJS" language="javascript">

    function failure(error)
    {
        var msgarea = document.getElementById("msgarea");
        msgarea.innerHTML += "Error retrieving Support Times info";
        msgarea.innerHTML += "<br>API Error: " + error.description;
        msgarea.innerHTML += "<br><br>Fault code: " + error.faultcode;
        msgarea.innerHTML += "<br><br>Fault string: " + error.faultstring;       
    }

    function initPage()
    {
   
        var msgarea = document.getElementById("msgarea");
   
        if ('{!$UserRole.Name}' != 'System Administrator')
        {
            msgarea.innerHTML = "We're sorry, but this button is under consturction and only for use by System administrators at the present time.  You will be returned to the previous screen.";
            window.location.href = "/{!Support_Time__c.Id}";
        }
        else
        {
            try
            {
                var myquery = "SELECT Engineer_Name__c, Date__c, Hours__c, Approved__c FROM Support_Time__c";
           
                // msgarea.innerHTML =    myquery+ '<br><br>';
                sforce.connection.query(myquery,{onSuccess :success,
                                                 onFailure:failure,
                                                 source : {output : msgarea,
                                                           startTime : new Date().getTime()
                                                          }
                                                }
                                       );       
       
            }
            catch (error)
            {
                msgarea.innerHTML += "EXCEPTION";
                msgarea.innerHTML += "<br>API Error: " + error.description;
                msgarea.innerHTML += "<br><br>Fault code: " + error.faultcode;
                msgarea.innerHTML += "<br><br>Fault string: " + error.faultstring;
            }
   
        }
    }


function success(queryResult)
{
    var msgarea = document.getElementById("msgarea");
    var outputarea = document.getElementById("outputarea");   

    if (queryResult.size > 0)
     {
         //get the records array
        var records = queryResult.getArray('records');
        var date = "";
        var hours = "";
        var approved = "";
        var output = "";
        var name= "";
        
         for (var i=0; i< records.length; i++)
         {
           date = records[i].Date__c;
           hours = records[i].Hours__c;
           approved = records[i].Approved__c;
           name = records[i].Engineer_Name__c;
           output += "<tr><td>"+name+"</td><td>"+date+"</td><td>"+hours+"</td><td>"+approved+"</td></tr>";
         }

    }
    else
    {
     output += "<tr><td>No Support Times found for {!Support_Time__c.Engineer_Name__c}</td></tr>";
    }

       outputarea.innerHTML = output;

}

</script>

</head>


<body onload="initPage()" class="Support_Times__c detailPage">
<DIV class=bPageTitle>
     <DIV class="ptBody secondaryPalette">
     <DIV class=content><IMG class=pageTitleIcon alt=Entity_Name src="/s.gif">
     <H1 class=pageType>Approve Multiple Support Time entries at once<SPAN class=titleSeparatingColon>:</SPAN></H1>
     <H2 class=pageDescription>Under Construction</H2>
 </DIV>
</DIV>
</DIV>
<DIV class="bPageBlock secondaryPalette">
 <DIV class=pbBody>
 <DIV class='pbSubsection' id='msgarea'>
 </DIV>
</DIV>
</DIV>

<table id="outputarea"></table>


</body>
</html>

werewolfwerewolf
Interesting.  What happens if you run that same query in Force.com Explorer?
bakumbakum
No problems there.  No problems in Eclipse either, using the SOQL tool.  Driving me crazy.
werewolfwerewolf
What if you run the query synchronously instead of asynchronously as you are here?