There are a lot of examples online which detail how to leverage Schema.getGlobalDescribe to see what objects and corresponding metadata there are in Salesforce.
Instead of leveraging code like this, which iterates over all sObjectField values from a given object, is there a way that one can iterate over all Salesforce objects and corresponding fields in one go? This way, I don't need to provide the objects one by one to get the fields.
The execute anon script I have tried so far doesn't compile and i'm wondering if i'm either making an obvious mistake or whether it is possible to iterate over all object fields in this manner.
String sep = ' - ';
Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
List<String> liObjects = new List<String>();
for (Schema.SObjectType obj : gd.values()){
Map<String, Schema.SObjectField> fieldMap = gd.get(obj).getDescribe().fields.getMap();
for (Schema.SObjectField sField : fieldMap.values()) {
schema.DescribeFieldResult dField = sField.getDescribe();
String fieldLabel = dField.getLabel();
String fieldAPIName = dField.getName();
String line = obj.getDescribe().getName() + sep + obj.getDescribe().getLabel() ;
liObjects.add(line);
}
}
system.debug('size of liObjects is: ' + liObjects.size());