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
J4J4 

Display the results of an Ajax query as an report for a custom object

Maybe this can help serve as an example for someone trying to get started:

Custom object: Conferences
SControl: ConferencesOfThisType
Reference the SControl as a Custom Button or Link Detail on the Custom Object



Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>{!Conference__c.Type__c} Technology Type Conferences</title> 
<script src="/soap/ajax/10.0/connection.js"></script>
<script src="/js/dojo/0.4.1/dojo.js"></script>

<script type="text/javascript" src="/static/031907/js/functions.js"></script> 
<script src="/dJS/en/1192057840000/library.js" type="text/javascript"></script> 
<script type="text/javascript" src="/static/031907/desktop/desktopAjax.js"></script> 
<link href="/sCSS/10.0/1190846266000/Theme2/default/elements.css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" type="text/css" /> <script type="text/javascript">try { DynamicCss.addCssUrl('/sCSS/10.0/1190846266000/Theme2/default/elements.css', 'handheld,print,projection,screen,tty,tv');} catch(e) {}</script> 
<link href="/sCSS/10.0/1190846266000/Theme2/default/common.css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" type="text/css" /> <script type="text/javascript">try { DynamicCss.addCssUrl('/sCSS/10.0/1190846266000/Theme2/default/common.css', 'handheld,print,projection,screen,tty,tv');} catch(e) {}</script> 
<link href="/sCSS/10.0/1184629367000/Theme2/dStandard.css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" type="text/css" /> <script type="text/javascript">try { DynamicCss.addCssUrl('/sCSS/10.0/1184629367000/Theme2/dStandard.css', 'handheld,print,projection,screen,tty,tv');} catch(e) {}</script> 
<link href="/sCSS/10.0/1192216564000/Theme2/00D7000000098sy/005700000012yQj/dCustom0.css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" type="text/css" /> <script type="text/javascript">try { DynamicCss.addCssUrl('/sCSS/10.0/1192216564000/Theme2/00D7000000098sy/005700000012yQj/dCustom0.css', 'handheld,print,projection,screen,tty,tv');} catch(e) {}</script> 
<link rel="shortcut icon" href="https://na5.salesforce.com/favicon.ico" /> 

<script>
  dojo.addOnLoad(init);

function init() {
  var callback = {
    onSuccess : displayResult,
    onFailure : displayError
  };
  sforce.connection.query("SELECT Id, Name, City__c, State__c, Type__c, Date__c, expected__c FROM Conference__c WHERE Type__c = '{!Conference__c.Type__c}' ORDER BY Date__c DESC NULLS last LIMIT 25", callback);
}

function displayResult(result) {
  var records = result.getArray("records");
  var html = [];

  html.push("<table class='list' border='0' cellspacing='0' cellpadding='0'>");
  html.push("<tr class='headerRow'><th scope='col' class=''>Conference Name</th><th scope='col' class=''>Technology Type</th><th scope='col' class=''>City</th><th scope='col' class=''>State</th><th scope='col' class=''>Expected Attendees</th><th scope='col' class=''>Date</th></tr>");
  for (var i=0; i<records.length; i++) {
  var record = records[i];
    if (i%2 == 0) {
   html.push("<tr class=' dataRow even first' onblur='if (window.hiOff){hiOff(this);}' onfocus='if (window.hiOn){hiOn(this);}' onmouseout='if (window.hiOff){hiOff(this);}' onmouseover='if (window.hiOn){hiOn(this);}'>");
    } else {
   html.push("<tr class=' dataRow odd last' onblur='if (window.hiOff){hiOff(this);}' onfocus='if (window.hiOn){hiOn(this);}' onmouseout='if (window.hiOff){hiOff(this);}' onmouseover='if (window.hiOn){hiOn(this);}'>");
    }
  html.push("<th scope='row' class=' dataCell '><a href=\"/" + record.Id + "\" TARGET=_BLANK>"  + record.Name + "</a></th>");
  html.push("<th scope='row' class=' dataCell '>"  + record.Type__c + "</th>");
  html.push("<th scope='row' class=' dataCell '>"  + record.City__c + "</th>");
  html.push("<th scope='row' class=' dataCell '>"  + record.State__c + "</th>");
  html.push("<th scope='row' class=' dataCell '>"  + record.expected__c + "</th>");
  html.push("<th scope='row' class=' dataCell '>"  + record.Date__c + "</th></tr>");

   }  
 html.push("</table>");
   document.getElementById("output-div").innerHTML = html.join("");
}

function displayError(error) {
  document.getElementById("output-div").innerHTML =
    "oops something went wrong ... " + error;
}
</script>


</head>

<body onLoad="if (this.bodyOnLoad) bodyOnLoad();" onBeforeUnload="if (this.bodyOnBeforeUnload) bodyOnBeforeUnload();" onUnload="if (this.bodyOnUnload) bodyOnUnload();" onFocus="if (this.bodyOnFocus) bodyOnFocus();" class="Custom24Tab overviewPage"> 

<!-- Main Body Starts Here --> 
<form name="sessiontimeout"> 
<input type="hidden" id="pageLoaded" value="0"> 
<input type="hidden" id="timeoutText" value="For
security reasons, your Salesforce session is about to time
out.&lt;br&gt;&lt;br&gt;What would you like to do—" /> 
<input type="hidden" id="continueButton" value="Continue Working" /> 
<input type="hidden" id="logoutButton" value="Logout" /> 
<input type="hidden" id="doTimeoutLocation" value="https://www.salesforce.com/login.jsp–ec=301&startURL=%2Fpage%2Ftimeoutrefresh.jsp%3Fsfdc.setJsDomain%3D1" /> 
<input type="hidden" id="doNotTimeoutLocation" value="/page/timeoutrefresh.jsp˜sfdc.setJsDomain=1" /> 
</form> 

<table class="outer" width="100%" id="bodyTable" border="0" cellspacing="0" cellpadding="0"> 
<!-- Start page content table --> 
<tr><td id="bodyCell"> 

<!-- Start page content --> 
<a name="skiplink"><img src="/s.gif" height='1' width='1' alt="Content Starts Here" class="skiplink" title="Content Starts Here"></a> 
<div class="bPageTitle"> 
<div class="ptBody secondaryPalette"> 
<div class="content"> <img src="/s.gif" alt="Conference" class="pageTitleIcon" title="Conference"/> 
 <h1 class="pageType">Conferences<span class="titleSeparatingColon">:</span></h1> 
 <h2 class="pageDescription"> &nbsp;</h2>
 <div class="blank">&nbsp;</div></div></div></div>

<!-- Begin RelatedListElement -->
<div class="bRelatedList">
<!-- Begin ListElement -->

<!-- motif: Custom24 -->

<!-- WrappingClass -->
<div class="hotListElement">
<div class="bPageBlock secondaryPalette">

<div class="pbHeader">
<form action="/a00/o" id="hotlist" method="GET" name="hotlist" onsubmit="if (window.ffInAlert) { return false; }" >
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="pbTitle"><img src="/s.gif" alt="" width="1" height="1" class="minWidth" title="" /><h3>{!Conference__c.Type__c} Technology Type Conferences</h3></td>
<td class="pbButton"><input value=" New " class="btn" name="new" onclick="top.window.location = '/a00/e™retURL=%2Fa00%2Fo';" title="New" type="button" /></td>
</tr></table></form></div>

<div id="output-div" class="pbBody">

</div>

<div class="pbFooter secondaryPalette"></div>

</div>
</div>

<!-- End ListElement -->
</div>
<!-- End RelatedListElement -->

<!-- Body events -->
<script type="text/javascript">
function bodyOnLoad() {
if (typeof(startSessionTimer)!='undefined') {startSessionTimer(); };
if (typeof(ActivityReminder)!='undefined') {ActivityReminder.initialize([], false, false);};
if ((window.sfdcPage) && (sfdcPage.executeOnloadQueue)){sfdcPage.executeOnloadQueue();};
}

function bodyOnBeforeUnload() {
if ((window.sfdcPage) && (sfdcPage.executeOnBeforeUnloadQueue)){sfdcPage.executeOnBeforeUnloadQueue();};
}

function bodyOnFocus() {
closePopup();
}

function bodyOnUnload() {
}
</script>
<script type="text/javascript">try { window.sfdcPage.appendToOnloadQueue(checkDebugLogWindowExists);} catch(e) {}</script>
<!-- End page content -->
</td>
</tr>
</table>

</div>
</body>

</html>