Dynamic SOSL

Similar to Dynamic SOQL we can create Dynamice SOSL.

Whenever a user is selecting a piece of information on a page and then he/she is submitting it to the Apex program. Then in that Apex program, we need to generate that SOSL query at one time. In this case, we will use Dynamic SOSL.

SOQL vs SOSL

SOQLSOSL
You know in which object the data you are searching for residesYou are not sure in which object the data might be.
The data needs to be retrieved from single object or related objects.You want to retrieve multiple objects and fields, which might not be related to each other.
SOQL queries can be used in Classes and Triggers.They are only supported in Apex Classes and Anonymous blocks.
We can perform DML operations on query result.We can not perform dml operations.
It returns records.It returns fields.
You can count retrieved records.You cannot count retrieved records.

Our Recent Blog

Share This Post