ApexCode示例
List<String> objectApiNameList = new List<String>(); // 传你想判断的对象
objectApiNameList.add('Account');
Schema.DescribeSobjectResult[] results = Schema.describeSObjects(apiNames);
for(Schema.DescribeSobjectResult describeResult : results){
System.debug(LoggingLevel.INFO, '*** 存在?: ' +
describeResult.fields.getMap().keySet().contains('phone'));
}
获取全部对象
Map<String, Schema.SObjectType> globalDescribe = Schema.getGlobalDescribe();
System.debug(LoggingLevel.INFO, '*** globalDescribe: ' + globalDescribe);
for(string objectApi: globalDescribe.keyset()){
// YOUR CODE
}