public static Map<String, decimal> getFieldsCount(String objectName){
Map<string,Schema.SObjectField> get_F_name=Schema.getGlobalDescribe().get(objectName).getDescribe().fields.getMap();
List<String> fieldlist=new List<String>();
for(String s:get_F_name.keySet())
{
fieldlist.add(''+get_F_name.get(s));
}
Map<String, decimal> fieldMap = new Map<String, decimal>();
String query1='SELECT Count(Id) FROM '+objectName;
AggregateResult aggr=Database.query(query1);
decimal totalRecordCount=(decimal)aggr.get('expr0');
for(String s:fieldlist)
{
String query='SELECT Count(Id) FROM '+objectName +' where ' +s +' != null';
AggregateResult aggrResults=Database.query(query);
decimal summ=(decimal)aggrResults.get('expr0');//totalRecordCount
fieldMap.put(s,summ*100);
System.debug('fieldmao '+s +' val '+summ*100);
}
return fieldMap;
}
the error message I am getting:- System.QueryException: Address fields can only be filtered using Distance expressions