You need to sign in to do that
Don't have an account?
jf317820
grabbing length of soql-r query
Code:
how do i get the length (or size) of the nested buildings query?
var buildings = sforce.connection.query("SELECT Id, (Select Id, Name, Building_Street__c, Building_City__c, Building_State__c FROM Buildings__r) FROM Site__c WHERE Deal__c = '{!Opportunity.Id}'");
how do i get the length (or size) of the nested buildings query?
thanks in advance
query by using the code below.
result = sforce.connection.query(...);
records = result.getArray("records");
for (var i=0; i<records.length; i++) {
var record = records[i];
var childQuery = record.Buildings_r;
if (childQuery) {
var buildings = childQuery.getArray("records");
alert(buildings.length);
}
}
See if you can use QueryResultIterator. It is much easier to use
with nested query. You can find an example here:
AjaxTools->samples->Query->join.
HTS
ok, the opportunity i'm working wiht right now has 2 sites (test.length represents the number of sites associated with the deal). one of the sites has 2 buildings, the other site has 1 building. I'm simply trying to output a list of the three buildings, but I can't seem to get these two "unnassociated" sets of buildings to play nice in the array so I can grab them and output them.
You can run this query in the debug shell. Just cut and paste
the query api call in the shell text box and press return. shell will display
the server response as a easy to read table. See if the server
is sending back all the details you are expecting.
Also note that the coloum heading name must be used to access
the value of that field in javascript.
HTHs,