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
vivinmathewvivinmathew 

Cannot retrive records

Hi,

I have developed a custom control which retrieves the threads posted in a custom object called Threadsnew_c.

I am in the process of developing a discussion forum in SFDC.

I able to retrive records when this query is executed in sfore xplorer. I have made this scontrol as a custom web control and when i run it from the interface that is SFDC i get values which says 'undefiend'.

Can someone please help me.

I have attached my coding HTML script with this.

Regards,
VIvin MathewCode:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>SalesForce SControl</title>
<link href="/dCSS/Theme2/default/common.css" type="text/css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" >
<link href="/dCSS/Theme2/default/custom.css" type="text/css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" >
<script src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js—browser=true" type="text/javascript"></script>
<script type="text/javascript" src="/js/functions.js"></script>
<script language="javascript">
<!--
//Page initialization is a good idea.  
function initPage() 
{
sforceClient.registerInitCallback(pageSetup);
//Including the two merge fields below will enable this sforce control when used in your account.  
sforceClient.init("{!API.Session_ID}", "{!API.Partner_Server_URL_70}", true);
}

function pageSetup() {
//Simple query call
//var qr = sforceClient.query("Select CreatedDate, Id, Name, Threadsnew_subject__c,Threadsnew_body__c  from Threadsnew__c order by CreatedDate DESC");
SearchString="Select CreatedDate, Id, Name, Threadsnew_subject__c,Threadsnew_body__c  from Threadsnew__c order by CreatedDate DESC";
var queryResult = sforceClient.Query(SearchString);
//if (qr.className == "QueryResult") {
// BUILD TABLE HEADER
var output = "<table width=’100%’ class=list border=’0’ cellspacing=’0’ cellpadding=’0’><tr class=headerRow height=20>";
output += "<th nowrap’>Thread Subject</th>";
output += "<th nowrap’>Author</th>";
output += "<th nowrap’>Posted Date</th></tr>";
//BUILD TABLE ROWS
for (var j = 0; j < queryResult.records.length; j++)
{
var Threadsnew__c = queryResult.records[j];
output += "<tr onmouseover=hiOn(this) onmouseout=hiOff(this)>";
output +="<td><a href=’/"+Threadsnew__c.Id+"’ target=_parent>" + Threadsnew__c.Threadsnew_subject__c + "</a></td>";
output += "<td>" + Threadsnew__c.Name+ "</td>";
output += "<td>" + Threadsnew__c.CreatedDate+ "</td></tr>";
}
output += "</table>";
document.getElementById("divMain").innerHTML = output;
}
//}
//-->
</script>
</head>
<body onload="initPage();">
<BODY class="account">
<form name=AccountSearchForm">
<DIV class=bPageTitle>
<DIV class="ptBody secondaryPalette">
<DIV class=content><IMG class=pageTitleIcon alt=Account src="/s.gif">
<H1 class=pageType>General<SPAN class=titleSeparatingColon>:</SPAN></H1>
<H2 class=pageDescription>Discussion Boards</H2>
</DIV></DIV></DIV>
<DIV class="bPageBlock secondaryPalette">
<DIV class=pbBody>
<DIV class=pbSubsection>
<div id="divMain"></div>
</form>
</DIV></DIV></DIV>
</body>
</html>

 

Ron HessRon Hess
This is using the old beta toolkit, and is not supported, the new, supported AJAX toolkit is fully documented on the WIKI

if you can switch to this new, suported toolkit, it will be much easier to debug the issue, probably take no more than an hour to switch.

vivinmathewvivinmathew
Hi,

Can you please help me or guide me to how to switch to the new tool kit.

Thanks,
Vivin Mathew
Ron HessRon Hess
Sure, the details are here

==========
Toolkit location
Beta Value:

https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js

Change to this value for version 9.0:

/soap/ajax/9.0/connection.js

Initialize with session ID
Beta Value:

sforceClient.init({!API_Session_ID}", "{!API_Partner_Server_URL_70}")

Remove for all versions after Beta. The AJAX Toolkit handles all session management once you log in.
Root variable
Beta Value:

sforceClient

Change to this value:

sforce.connection

Entity object
Beta Value:

DynaBean

Change to this value:

sforce.SObject


So, the header for my latest scontrol looks like this
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html> <head> 
<title></title> 
<link  href="/dCSS/Theme2/default/common.css" type="text/css" rel="stylesheet" >
<link  href="/dCSS/Theme2/default/custom.css" type="text/css" rel="stylesheet" >
   <script type="text/javascript" src="/js/functions.js"></script>
    <script src="/soap/ajax/9.0/connection.js"></script>
    <script src="/js/functions.js" type="text/javascript"></script>
<script src="/dJS/en/library.js" type="text/javascript"></script>

<script type="text/javascript" language="JavaScript1.2" > 


and the setup code looks like this, note no init() for the toolkit this is done for you
Code:
function setup() { 
 var qbean = new sforce.SObject("SFDC_Action_Plan__c");
 
 var desc = sforce.connection.describe('SFDC_Action_Plan__c'); // need field defs
 
 var qfields = desc.toUpdateFieldNames(); // list the editable fields , skip the read only
 var soql = "select Id," + qfields + " from SFDC_Action_Plan__c where id = '{!SFDC_Action_Plan__c.Id}'";

 queryResult = sforce.connection.query(soql); 
 setTimeout("clone_plan()",100);
}

Be sure to access the  query results records using getArray()

Code:
 var recordArray = queryResult.getArray('records');

 
And here is my caching version of describe, which is not included in the base toolkit but i needed a cache for this call ( i probably should have used a different namespace, but it works..)

Code:
sforce.Connection.prototype.describeCache = {};

sforce.Connection.prototype.describe = function(table) {
    if (this.describeCache[table]) return this.describeCache[table];
    this.describeCache[table] = this.describeSObject(table);
    return this.describeCache[table];
}

 
And, looks like my function toUpdateFieldNames() got pasted in, so here it is also
Code:
sforce.Xml.prototype.eachField = function (iterator) {
  for (var f in this.fields) {
        var field = this.fields[f];
        if (field) iterator(field);
  }
}

// return list of fields used to create a clone
sforce.Xml.prototype.toUpdateFieldNames = function () {
   var sb = [];
   this.eachField(  
    function (f) { 
     if (f.getBoolean('updateable') || f.getBoolean('createable') )
      { 
       sb.push( f.name); 
      }
    } 
   );
   
   var ret = sb.join(', ').replace(/[, ]+$/g,'');
   return ret;
}

 

Message Edited by Ron Hess on 04-03-2007 07:50 AM