Deep Banerjee

Have you ever had a requirement to query all the fields of an object?

Let’s say you’re working on building a managed package to push to Salesforce AppExchange or building a data extensive component where you need to query dynamically.

You can easily do that the following way

Now , let’s talk about another scenario where you need to query only certain fields of an object conditionally.

We can achieve this by following

  1. Creating a configurable fieldSet on the object
  2. Passing this fieldset and object api as parameters to apex class to build soql the following way

This way by configuring the fieldset we can change the soql query as per the business requirement.

Hope you enjoyed reading this :)

To understand more about soql , you can read this article .

--

--