You need to sign in to do that
Don't have an account?
Error with related list
Hi,
Right now I have a Car__c custom object which has a many-to-many relationship with Feature__c, (the relationship is under an object named Car_Features__c).
In my code, on the visualforce side I have outputted {!Car__c.Features__r} which shows the correct related list under the car. (Shows the ids of the features in the car)
But when I do the same thing on the apex side and try to output it, the list is empty:
selectedCar is the Id parameter delivered from the visualforce side via commandlink.
CurrentCar = [SELECT Id,Name,Description__c FROM Car__c
WHERE Id = :selectedCar];
String msg = ' ';
List<Car_Features__c> CurrentFeats = CurrentCar.Features__r;
msg += CurrentFeats;
Return msg;
The msg should output the id's of the Car_Features__c in the related list, the same way that the {!Car__c.Features__r} call on the visualforce side does.
However, the output shows msg to be empty, but printing out the Id of CurrentCar prints the correct car Id, so that is not the issue.
Any ideas?
Thanks.
CurrentCar.Features__r is essentially an array of Car_Features__c objects, but you have to populate that via the SOQL query - the platform won't fill out the object graph from the car record for you.
Thus you'll need something like