objects - Insurance Software development

Salesforce Script To Fetch Object

Author - Webner
12:51 pm
1 Comment
| |

Salesforce script to fetch object which contains fields using fields API

When we work with objects in salesforce, sometimes we need a few things dynamically like a list of object names that contain field with a given API name of the field. So, here is a script that gives us all the objects which contain those fields.

String fieldAPI = ‘fieldAPI__c’; // API name of field to be searched
List sObjectList = new List();

//fetching objects which will be used to get field names
for(Schema.SObjectType eachShema : Schema.getGlobalDescribe().Values()){
String objectName = eachShema.getDescribe().getName();

// Exclude all the unwanted sObjects […]

Contact Us