function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Phuc 2Phuc 2 

Retrieve object from org based on condition

I need to retrieve the objects from an org only iff they have a field set associated to them.  I know how to retrieve the sObjects from the org but is there a way to only retrieve the sObjects that have at least 1 field set associated to them?

Thnak you,
Michael
Santosh Joshi 11Santosh Joshi 11
Yes, it is possible to retrieve only the sObjects that have at least one field set associated with them.
You can do this by using the Salesforce Metadata API to retrieve a list of all field sets in your org, and then comparing the fields in each field set to the fields in the sObjects you want to retrieve.
Here are the general steps to achieve this:
Use the Metadata API to retrieve a list of all field sets in your org.
Loop through each field set and retrieve its associated sObject type.
Use the Salesforce Object Metadata API to retrieve the metadata for the sObject type.
Compare the fields in the field set to the fields in the sObject metadata.
If there is at least one matching field, retrieve the sObject records.
By following these steps, you can ensure that only sObjects with at least one associated field set are retrieved from your org.
Smart VanillaSmart Vanilla
Thanks for sharing useful information with us. It is really helpful to me. I always prefer to read the quality content and this thing I found lcpsgo (https://www.lcpsgo.us/) in your post. thanks for sharing with us.
Eden WheelerEden Wheeler
 To retrieve only the sObjects from your Salesforce org that have at least one field set associated with them, you can follow these steps:
  • Retrieve all sObjects from the org using a describe call.
  • Iterate through the sObjects and perform a describe call on each sObject to check for field sets.
  • Include the sObject in your final list if it has at least one field set associated with it.
  • By following these steps, you will have a list of sObjects that meet your criteria.