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
kylew@mbs-us.cokylew@mbs-us.co 

Query CustomObject in scontrol

I've been trying to figure this out for the last two days. I've gone through countless posts and I just don't see my problem. I've created a customobject called residual (residual__c). I've imported some data in to it. I've used the apex data loaded to verify that there is data in it. I then created an scontrol and put it on my accounts page layout but when the scontrol runs all I get is either null or undefined inside of the table cell.
 
Code:
<html> 
<head> 
<script src="/soap/ajax/9.0/connection.js"></script> 
<script>
function createTable() 
{
  var queryContact = sforce.connection.query("SELECT id,report_date__c,residual__c,gross_monthly_volume__c FROM residual__c where name='{!Account.AccountNumber}'");
  var records = queryContact.getArray("records"); 
  htmlstr="<TABLE width=100% class=pbBody border=0>"; 
  htmlstr+="<tr><TH>Report Date</TH><TH>Gross Monthly Volume</TH><TH>Residual</TH></TR>"; 
  for (var i = 0; i < records.length; i++) 
  { 
    htmlstr+="<tr>" +
             "  <td>" + records[i].report_date__c + "</td>" +
             "  <td>" + records[i].gross_monthly_volume__c + "</td>" +
             "  <td>" + records[i].residual_date__c + "</td>" +
             "</tr>";
  }
  htmlstr+="</TABLE>"; 
  document.write(htmlstr);
} 
</script>
</head>
<body onload="createTable();"></body>
</html>

 
I've also used records[i].get("report_date__c"), stored the data in variables, used the alert function, but all seems to give the same result. My data isn't pulling correctly. Can someone see what I'm doing wrong?
 
Thanks
 
Kyle
cheenathcheenath
Check if the user have permission to view this data.

You can also see what the query returned by going to the debugshell:

1. log in as the right user
2. go to /soap/ajax/10.0/debugshell.html
3. type your query and hit return:
sforce.connection.query("SELECT id,report_date__c,residual__c,gross_monthly_volume__c FROM residual__c");

Debug shell will display the result as a table.



kylew@mbs-us.cokylew@mbs-us.co
I typed in the query and the results were just as I expected. I must not be storing the data correctly when it comes back
cheenathcheenath
If the query retruned expected result then records[i].field_name should have the right value.

field_name is case  sensitive.  So  make sure that you  are using the right case.

 
kylew@mbs-us.cokylew@mbs-us.co
thank you. It was the case sensitivity.