Here's my query that works in workbench when run with just soql. I lose the subquery data when I try to add the Contact to a list. ContactHolidayAssociations is a junction object between Holiday and Contact.
contacts = [SELECT firstName, lastName, Id, Account.Name, Account.Id, (SELECT Name, Holiday__r.Id, Holiday__r.Holiday_Name__c
So when I do a System.debug with the contacts list, no Holiday data shows. Holiday data does show when running the same query in workbench.
What am I missing?
I'm trying to access a junction object on Contact. This object is to build a many-to-many relationship between Contact and Holiday__c. I drill down into each Account to display info from Opportunity and Contact. I can get to all the data except the junction object on a Visualforce page. My junction object is ContactHolidayAssociations__c
I get this error:
Save error: SOQL statements cannot query aggregate relationships more than 1 level away from the root entity object.
accounts = [select name, owner.name, (select FirstName, LastName, Id, (Select Id, Name, Holiday__r.Holiday_Name__c From ContactHolidayAssociations__r) from Contacts), (select Name from Opportunities) from Account ];
Can someone suggest a way around this?