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
JohnCutJohnCut 

Trouble with nested Arrays and queries

Hello Folks. I am new to JavaScript, and have hit a wall. I am attempting to get a basic relationship query to work:

sforce.connection.query(
   "Select Id, Account.Name, Amount From Opportunity limit 30",
   callback);

When I take a look at the Array:

//get the records array
var records = queryResult.getArray('records');
recordstring = records.join(";")
sforce.debug.log(recordstring)

I get something like this in the output window:

{type:'Opportunity', Id:'00660000008GofYAAS', Account:{type:'Account', Id:null, Name:'Gift Collector.com', }, Amount:'25350.0', };
{type:'Opportunity', Id:'00660000008GqscAAC', Account:{type:'Account', Id:null, Name:'Federal Signal', }, Amount:null, }

This looks workable, but I can't figure out how to extract the Account information. The Opportunity data works great ([array].Id, [array].Amount), but I'm at a loss with the Account info. I tried something like array[i][3][1], but that didn't seem to work.

Even the tiniest hint would be greatly appreciated.

John


cheenathcheenath
Plese check out this post.

In this specific case you have to do:

records[0].Account.Name

HTHs,