使用Schema类的describesSObjects方法获取描述sObject结果.使用此方法可以通过sObject类型名称描述一个或者多个sObject描述信息。
//sObject types to describe
String[] types = new String[]{'Account','Merchandise__c'};
//Make the describe call Schema.
DescribeSobjectResult[] results = Schema.DescribeSObjects(types);
System.debug('Got describe information for '+ results.size() + 'sObjects.');
//For each returned result, get some info
for(Schema.DescribeSObjectResult res : results) {
    System.debug('sObject Label:'+res.getLabel());
    System.debug('Number of fields:'+res.fields.getMap().size());
    System.debug(res.isCustom()?'This is a custom object.':'This is a standard object.');
    Schema.ChildRelationship[] rels = res.getChildRelationships();
    if(rels.size()>0){
        System.debug(res.getName() + 'has' + rels.size() +'child relationships.');
    }
}

 

 首先给大家看一下结果:

67、saleforce的object的describe方法使用

 

相关文章:

  • 2022-12-23
  • 2021-08-21
  • 2021-08-14
  • 2022-01-10
  • 2021-07-09
  • 2021-07-12
  • 2022-12-23
  • 1970-01-01
猜你喜欢
  • 2021-06-29
  • 2022-12-23
  • 2022-03-06
  • 2021-08-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案