I am trying to fetch the fields and their types of few Sobjects dynamically and trying to use these to query and do some operations.
Code below for reference :
Schema.DescribeSObjectResult d = Schema.Sobjecttype.CustomObject__c;
Map<String,String> fMap = new Map<String,String>();
Map<String, Schema.SObjectField> M = d.fields.getMap();
List <Schema.SObjectField> fieldList = M.values();
for(Schema.SObjectField aField: fieldList){
Schema.DescribefieldResult fieldDes = aField.getDescribe();
fMap.put(fieldDes.getName(),String.valueOf(fieldDes.getType()));
}
return fMap;
The map returned here contains a field which is not available in the object description. May I know what is causing this issue and where the fields are coming from.
Exception that I get while building the query with the above returned fields is System.QueryException: No such column 'LastReferencedDate' on entity 'CustomObject__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.
Thanks in advance for any help!