+ Start a Discussion

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.

Ankit Gupta@ DeveloperAnkit Gupta@ Developer

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 :

Mani Cube84Mani Cube84

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