I'm trying to write controller which will get all the standard and custom objects from org and display them in picklist; after selecting the Object name
from this Picklist – one PageblockTable should appear with related records below.
I'm trying to write controller which will get all the standard and custom objects from org and display them in picklist; after selecting the Object name
from this Picklist – one PageblockTable should appear with related records below.
Best Answer
To get the list of all objects in your org, you can use something like this:
Run that in the Developer Console and you will see a long list of Object names:
Note this includes every object in your schema, including Custom objects and even things like Knowledge article types and field_history tracking objects...
To put that into a picklist, in the Apex controller of your Visualforce page, instead of
System.debug
- build a list of Options:and on your page:
Now you have a picklist of all your options.
Use
actionFunction
to run an "onclick" on that, or perhaps just some javascript, or a normalapex:button
to submit the value back to the controller, and then useSchema
again to get all the related lists for that object:(where
selectedOption
is what was picked in the picklist).Now you have a List of all the related object names! Use it as you will
(and don't forget test coverage!)