+ Start a Discussion
pinal2pinal2 

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!

 

 

gv007gv007

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..

 

 

pinal2pinal2

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.

 

Thanks!

gv007gv007

where are you storing yours external system data.

pinal2pinal2

I can store them in the database. Thanks!

gv007gv007

force.com or some other external DB

pinal2pinal2

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