You need to sign in to do that
Don't have an account?
Salvatore Gomez
Return data fields from Multiple sobject in single query to visualforce page
I always seem to struggle with returning data fields from Multiple sobject in single query to visualforce page. Every time i try to display one of the opportunity fields in a visualforce page with a query similar to below i always get a invalid field for sobject error which I get because the list type is an account. I'm just trying to understand what is the best method for retrieving the result set from the below query and displaying it in visualforce. any help is greatly appreciated, thanks in advanced.
List<Account> Acc = new List<Account>();
Acc = [SELECT Id,Name,PersonEmail
,(Select Attachment.Id, Attachment.ParentId from Account.Attachments where Name='Contact Picture',(SELECT Opportunity.PLAN_DESCR__c,Opportunity.ADMIT_TERM_DESCR__c,Opportunity.JOB_TITLE__c,Opportunity.AccountId FROM Account.Opportunities)
FROM Account Where Id in
(SELECT AccountId FROM Opportunity where PLAN_DESCR__c='Business Analytics' and ADMIT_TERM_DESCR__c='2016 Fall')
limit 20
];
List<Account> Acc = new List<Account>();
Acc = [SELECT Id,Name,PersonEmail
,(Select Attachment.Id, Attachment.ParentId from Account.Attachments where Name='Contact Picture',(SELECT Opportunity.PLAN_DESCR__c,Opportunity.ADMIT_TERM_DESCR__c,Opportunity.JOB_TITLE__c,Opportunity.AccountId FROM Account.Opportunities)
FROM Account Where Id in
(SELECT AccountId FROM Opportunity where PLAN_DESCR__c='Business Analytics' and ADMIT_TERM_DESCR__c='2016 Fall')
limit 20
];
Try this query
Did you tried it in workbench ?
Thanks, yes the query worked fine in both workbench and the developer console. how would I return the result set of this query to display in a visualforce data table?