Sample Code:
- Set < String > listsObjs = new Set < String > {‘Account’, ‘Lead’};
- Map<String, Schema.SObjectType > globalDescription = Schema.getGlobalDescribe();
- for ( String obj : listsObjs ) {
- Schema.sObjectType objType = globalDescription.get( obj );
- Schema.DescribeSObjectResult r1 = objType.getDescribe();
- Map<String , Schema.SObjectField > mapFieldList = r1.fields.getMap();
- for ( Schema.SObjectField field : mapFieldList.values() ) {
- Schema.DescribeFieldResult fieldResult = field.getDescribe();
- String fieldLabel = fieldResult.getLabel().toLowerCase();
- Schema.DisplayType fielddataType = fieldResult.getType();
- if ( ( fieldLabel.contains( ‘address’ ) || fieldLabel.contains( ‘state’ )
- || fieldLabel.contains( ‘street’ ) || fieldLabel.contains( ‘city’ )
- || fieldLabel.contains( ‘postal’ ) || fieldLabel.contains( ‘zip’ ) )
- && ! fieldResult.isCalculated() ) {
- System.debug ( objType + ‘.’ + fieldResult.getName() );
- }
- }
- }
In the Developer Console, select Debug Only to see the debug logs.