I have a list of VisualForce components called VFComponent, a list of attributes name VFAttributes and a junction object VFComponentToAttribute that links them in a many to many relationship.
I am trying to get a list of components, in the form of:
List<VFComponent__c> VList = [Query here FROM VFComponentToAttribute];
For the query I have tried getting Id, VFComponent__r.Id, VFComponent all to no avail. Everything I try seems to give me a type error.
Could someone be kind enough to explain how I could get a list,populated with child objects from the junction object in this way.
To clarify I am trying to pass a list of objects to some other code, but in general I would like to better understand what Salesforce actually stores in the junction object, I thought is was something like a key, but if I query the Id and try to use that I get type mismatches as well:
List<Id> idList = [Select childobject__r.id From JuncitonObject];
That gives me also gives an error as if the query result were objects and not IDs, which I suppose they are?
In short I am confused.
Best Answer
Okay, this was due to my own ignorance (well I knew that going in or I would not have posted here).
Anyhow, the problem is that any query on an object returns a list of that object. You then have to get the list of identifiers into a separate list using a loop.
So for instance the following works to run another class on the VFComponent object using a list of Ids for VFComponent from the VFComponentToAttribute object:
But if anyone else would like to suggest a more elegant solution I would be glad to hear it.
Also is there any way to find the true structure of the underlying database that Salesforce uses? I think this would be a lot less confusing if I knew what the code actually mapped to.