You need to sign in to do that
Don't have an account?
JohnCut
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
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
In this specific case you have to do:
records[0].Account.Name
HTHs,