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
JohanButsJohanButs 

S-Control and Ajax

I also posted this thread in the java forum but i didn't get any response there so i'll try it here. I have a problem concerning the query method in the ajax toolkit (both tested with beta 1 and beta 2). What i want to do is the following: I want to create a treeview with different categories and each categorie has his items. So i build up my own control instead of using other be just hiding en showing divs. An example of a simple tree looks like this:

Code:

<DIV id=category>category</DIV>
  <DIV id="categoryitems" onclick="setChecks(this);">
    <DIV id=item1><INPUT id=citem1 type=checkbox>item1 in category</DIV>
    <DIV id=item2><INPUT id=citem2 type=checkbox>item2 in category</DIV>
  </DIV>

 

When i click on category i have the following code that query's for each item in the categoryitems section for that category:

Code:

function setChecks(parentobj) {	 //parentobj = categoryitems	
	var pobj = parentobj;
	var counter = pobj.childNodes.length;   //= 2
	for (i=0;i<counter;i++) {
		var parchild = pobj.childNodes[i];
		query(parchild.id);				
	}	
}


 Code:

function query(id) {
	document.getElementById("erroroutput").innerHTML += "<br> Select Id from Node_Item__c Where Account__c = '{!Account_ID}' And Path__c = '" + id + "'";
	var qr = sforceClient.Query("Select Id from Node_Item__c Where Account__c = '{!Account_ID}' And Path__c = '" + id + "'");
	
	if (qr.getClassName() == "QueryResult") { 
		if (qr.size > 0) {
			document.getElementById("erroroutput").innerHTML += "<br><b>found for:</b>" + id + qr.records[0].get("Id");
			//normally i set the checkbox for that item to true
		} else {
			document.getElementById("erroroutput").innerHTML += "<br><b>not found for:</b>" + id;
			//i set the checkbox for the item to false
		}
	} else {
		document.getElementById("erroroutput").innerHTML += "<br><b>no valid queryresults found for:</b>" + id;
	}					
}

 

In the query method i simply output some debug info into a div. Before showing the result, i have for the 2 items (with id=item2 and id=item1) a record in salesforce so they exist. The result in the debug div output when i execute is the following:

Select Id from Node_Item__c Where Account__c = '00130000009onzj' And Path__c = 'INST_BASE_INF_NAPP' found:INST_BASE_INF_NAPPa0330000000jisDAAQ

This is ok but then it stops my for loop and doesn't execute the query anymore for the second item although there is a record. The weird thing is when i only debug and not call the sforceClient.query() it does the loop 2, so i think the problem doesn't exist in my code but in the query method. Is this a known bug or am i using bad code ?

DevAngelDevAngel
Hi Johan,

Which version of the ajax toolkit are you currently using?
Beta3 is current available at https://www.sforce.com/ajax/beta3/sforceclient.js

Try putting a try catch block around the outer most function.
darozdaroz
Dave,

On a related note - is there anywhere you have, can link to, or can post a changelog from version to version? It would be nice to know what has changed to see what bugs get fixed, and where code was altered to look for new ones.
DevAngelDevAngel
Going forward this toolkit will be treated with the same processes as the web service api itself.

The biggest change you will notice in the beta3 version is that all the objects have been namespaced with Sforce. So, creating a new dynabean looks like var contact = new Sforce.Dynabean("Contact").

I'm in the process of writing up a blog entry for this version that goes into more detail. We've been keeping this version close to the vest so that we could get additional testing and iterations in so you all would not have to.

There are currently 3 or 4 know bugs already with the beta 3, so unless you must have data binding, I would stick with the version that you are using.
darozdaroz

DevAngel wrote:
Going forward this toolkit will be treated with the same processes as the web service api itself.


Being a "beta" I wouldn't necessarily subject it to the full-blown proceess of Q&A, especially if it will speed development along... What I was hoping for was more of a rough guideline, a coders changelog if you will, summarizing the altered sections. Have looked at the beta3 code a few weeks ago by accident (that was a nasty typo) I understand that "we changed everything" would likely be the answer for this one... ;)


DevAngel wrote:
The biggest change you will notice in the beta3 version is that all the objects have been namespaced with Sforce. So, creating a new dynabean looks like var contact = new Sforce.Dynabean("Contact").

I'm in the process of writing up a blog entry for this version that goes into more detail. We've been keeping this version close to the vest so that we could get additional testing and iterations in so you all would not have to.

There are currently 3 or 4 know bugs already with the beta 3, so unless you must have data binding, I would stick with the version that you are using.


That's good info to know. Thanks Dave.
gokubigokubi
I look forward to that blog post!

Keep up the good work,
Steve
Randall PetitRandall Petit
How about printing shirts through this algorithm : https://heatedgadget.com/best-heated-jackets-for-women/