Guest User

Untitled

a guest
Jul 18th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. public with sharing class TestBrowseObjects {
  2. public TestBrowseObjects() {
  3. // Make the describe call
  4. String [] types = new String[]{'Case', 'Asset_Modules__c','Asset_History__c'};
  5.  
  6. Schema.DescribeSobjectResult[] results = Schema.describeSObjects(types);
  7.  
  8.  
  9. // For each returned result, get some info
  10. for(Schema.DescribeSobjectResult res : results) {
  11. Map<String, Schema.SObjectField> fieldMap = res.fields.getMap();
  12. // go over the field map, look for reference to 'Asset'
  13. for( String fieldName : fieldMap.keySet() ) {
  14. Schema.SObjectField field = fieldMap.get( fieldName );
  15. Schema.DescribeFieldResult fieldDescribe = field.getDescribe();
  16. Schema.SObjectType reference = fieldDescribe.getReferenceTo();
  17. if ( reference.getDescribe().getName() == 'Asset')
  18. {
  19. system.debug('fieldDescribe.referenceto == ' + fieldDescribe.referenceto);
  20. }
  21. }
  22. }
  23. }
  24. }
Add Comment
Please, Sign In to add comment