+ Start a Discussion
RajaMohanRajaMohan 

Dynamic SOQL to query list of sObjects at once

Hi Folks,

I am trying to query differnt sObjects like Account, Contact, Opportunity and two other custom objects in an instant. If any of the record is related to any other object then I am taking it dynamicaly and querying that particular record ID.

The problem is, The queries are coming under for loop at the moment. I am wondering if there is any chance to query the list of sObjects in a single query to avoid this.

Please suggest me a way to proceed with this.

Thanks
Raja
Ankit Gupta@ DeveloperAnkit Gupta@ Developer
Hi,

For query more than one object at a time you can use the SOSL.

This will return the list of sobjects.

Refer the below link as reference :

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dynamic_sosl.htm
Mani Cube84Mani Cube84
Hi, 

Iam looking for the same senario can any one find the solution for this.