是否可以获取对象上所有字段的所有API名称的列表?
Schema.DescribeSObjectResult r =Object__c.sObjectType.getDescribe();
List<String>apiNames = new list<String>();
for(Schema.DescribeSObjectResult result : r){
apiNames.add(); //this is where I am lost.
}
您可以使用fields方法获取Schema.SObjectTypeFields。
Schema.DescribeSObjectResult r = Account.sObjectType.getDescribe();
List<String>apiNames = new list<String>();
for(string apiName : r.fields.getMap().keySet()){
apiNames.add(apiName);
}
System.debug(apiNames);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句