2

Background. My manager asked me to retrieve all currency fields for many custom objects.

Amongst them there was at least one object with many fields which have field access Hidden. Let's call that object "Some Big Object". Field Access Level Mock

I was trying to execute following code snippet

String s1 = '';
String s2 = '';
for ( Schema.sObjectField fi : Schema.SObjectType.Some_Big_Object__c.fields.getMap().values() ){
    s1 += fi.getDescribe().getLabel() + '; ';
}
for ( Schema.FieldSet fi : Schema.SObjectType.Some_Big_Object__c.fieldSets.getMap().values() ){
    s2 += fi.getLabel() + '; ';
}
System.debug(LoggingLevel.ERROR, '!!!.  1 ' + s1 );
System.debug(LoggingLevel.ERROR, '!!!.  1 ' + s2 );

However, to my great surprize, this didn't retrieved any of hidden fields.

So the list in debug log was following:

Big Object Name; Deleted; Created Date; System Modstamp; Owner ID; Last Modified By ID; Created By ID; Last Modified Date; 

Missing Field in Result Set while I was expecting to see "Some Field To Retrieve" amongst this list.

Does anyone know if there exists any kind of lifehack to retrieve list of ALL fields of some object including hidden ones?

1 Answer 1

-1

You should try this snippet:

schema.getGlobalDescribe().get(SObjectType).getDescribe().fields.getMap().keySet()

Also all fields with the hidden one you could get when you execute your code in the scope of some custom Apex Class, in anonymously window you never get those fields.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .