You need to sign in to do that
Don't have an account?
sforce.QueryResultIterator for nested queries
I'm creating a customized button. The Query is a nested one as follows:
var primaryContact = sforce.connection.query("SELECT Account.Name, (SELECT Contact.FirstName FROM OpportunityContactRoles) FROM Opportunity WHERE Id='{!Opportunity.Id}'");
The query is a success. But I'm not able to access Contact.FirstName using sforce.QueryResultIterator. The error read: "Can not read property FirstName of undefined". My code is:
if ( primaryContact .size > 0) {
var it = new sforce.QueryResultIterator(primaryContact );
while (it.hasNext()) {
var query = it.next();
var firstName = query.OpportunityContactRoles.Contact.FirstName;
}
}
Please let me know how to access FirstName using the sforce.QueryResultIterator.
var oit = new sforce.QueryResultIterator(primaryContact);
while(oit.hasNext()){
var oppor = oit.next();
var OppConRoleFirstName = [];
if(oppor.OpportunityContactRoles){
var oppRole = new sforce.QueryResultIterator(oppor.OpportunityContactRoles);
while(oppRole.hasNext()) {
var OppCOntRol = oppRole.next();
OppConRoleFirstName.push(OppCOntRol.Contact.FirstName);
}
}
}