I am trying to populate a Set with values dynamically generated from a given object.
SObjectType objectName = Schema.getGlobalDescribe().get('Account');
Map<String,Schema.SObjectField> fields = objectName.getDescribe().fields.getMap();
Set<String> accountFields = new Set<String>{};
for(Schema.SObjectField fieldApiName: fields.values()) {
accountFields.add(fieldApiName);
system.debug(fieldApiName);
}
Using this code however returns an incorrect signature error:
Method does not exist or incorrect signature: void add(Schema.SObjectField) from the type Set