function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Retrieving multiple SObjects

Hello everyone,


I have a scenerio where I need to show multiple sObjects ( for eg: Account, Contact etc) information in the same page in one request. If I am correct, I think I can create a custom controller which can invoke these objects to retrieve the data. The question I have is the controller can be bind to only one sObject at a time, in this case Account or Contact. So, Should I create an another custom object which will have these two sObjects as an attribute so that I can bind the custom object to the custom controller for just rendering purpose?  What is the best design approach?


Thanks for your valuable response in advance!




if you want get all the sobjects in a single query use dynamic apex schema.describsobjet then you will get in a single query and disply it using vf page..




Hi, I have a follow up question. Say, I have a requirement to fetch a small amount of data from external systems (I can use Webservices API) but I don't store that small amount of data into database. In this case, can I display the data I retrieved from external systems AND mulitple sObjects in one page with a single request? In this case, I think I have to create a custom object and have sObjects and the data from external systems as an attribute/properties in the custom object. Bind this new custom object to custom controller for rendering purpose. Am I right? Is there a better way to do it? Sorry, I do understand the requirement I stated is very unorthodox, I am purely make up the requirement to know how to design if such complex scenerio do arrive.




where are you storing yours external system data.


I can store them in the database. Thanks!

gv007gv007 or some other external DB


In an db. Is it different if I store in external db.