I need to dynamically retrieve the list of fields for history objects, whether it be Asset or Opportunity etc. I normally use the following code to retrieve these fields for standard and custom objects:
String SobjectApiName = 'Asset';
Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Map<String, Schema.SObjectField> fieldMap = schemaMap.get(SobjectApiName).getDescribe().fields.getMap();
String apiNames = '';
for(String apiName : fieldMap.keyset())
{
if(fieldMap.get(apiName).getDescribe().isUpdateable()) {
apiNames += apiName + ',';
}
}
system.debug(apiNames);
But this does not work for History objects.
How can I retrieve the list of field api names for say, "AssetHistory"?