Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public with sharing class TestBrowseObjects {
- public TestBrowseObjects() {
- // Make the describe call
- String [] types = new String[]{'Case', 'Asset_Modules__c','Asset_History__c'};
- Schema.DescribeSobjectResult[] results = Schema.describeSObjects(types);
- // For each returned result, get some info
- for(Schema.DescribeSobjectResult res : results) {
- Map<String, Schema.SObjectField> fieldMap = res.fields.getMap();
- // go over the field map, look for reference to 'Asset'
- for( String fieldName : fieldMap.keySet() ) {
- Schema.SObjectField field = fieldMap.get( fieldName );
- Schema.DescribeFieldResult fieldDescribe = field.getDescribe();
- Schema.SObjectType reference = fieldDescribe.getReferenceTo();
- if ( reference.getDescribe().getName() == 'Asset')
- {
- system.debug('fieldDescribe.referenceto == ' + fieldDescribe.referenceto);
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment