You need to sign in to do that
Don't have an account?

Accessing Fields from Subselect
Hi,
we are currently a bit stuck at referencing the correct data that fit our needs.
Currently we are rendering a new line in calendar for any Rental Period in the database. The Rental Period contains a relationship to another custom object, which holds the product the customer has rented.
Right now, a new line is rendered for every Rental Period, regardless of periods that have the same product.
We would like to be able to do a subselect query to get every period start date for every product.
The subselect currently looks like this:
Select (Select Start__c, End__c From Rental_System__r) From Rental_Systems__c
From this subselect, we need to access specific fields.
I tried accessing Start__c on the VIsualforce page and in the Apex controller as you would do it for a 'normal' select query but that was not very successfull ;)
Is it in any way possible to directly access the values in the query?
Regards,
hoomel
I figured out how to access the fields i needed:
The page:
The class:
As you can see, I accessed the fields of the subselect with nested <apex:repeat>-tags.
Maybe someone can use this.
Regards,
hoomel
All Answers
you need to do something like below to get child object rows in a list.
hope this helps !!
Is it correct, that i only get one record into the 'contacts' list ?
When i try to add every contact to a list in the for loop, i get an error 'List has no rows for assignment to SObject' .
Just to be sure that this is what i need:
I would like to have a list of Rental Periods.
The only limitation is, that i need when i retrieve the list, i want to have only one entry for every Rental System, which contains all the Rental Periods with all their start and end dates.
Can you achieve this somehow?
I figured out how to access the fields i needed:
The page:
The class:
As you can see, I accessed the fields of the subselect with nested <apex:repeat>-tags.
Maybe someone can use this.
Regards,
hoomel