+ Start a Discussion

Getting a list of all SObjet fields - visible or not.


If a field is not visible,  sobject.fields.getMap() does not return that field. I was hoping it did and then I could check if the field is visible to current user (through isAccessibe)


In EE/UE, if I made a field invisible through field level security, this function does not return it.

In PE, if I remove it from screen layout,  the field is not returned either.


Is there another way? Seems like a bug that SFDC would not return all fields, but provide isAccessible function....


FYI, isAccessibile is inconsistent. If I remove from screen layout in EE/UE edition, it still return true. In the UI, it shows it as hidden under  Admin Setup->Security Controls->Field Accessibility). In Apex, it seems to mean visiblilty.





Could you have the class be defined "without sharing" so that it doesn't take the current user's access into account?
Regarding isAccessible: I disagree about it being inconsistent When you remove it from page layout in PE, in practise you actually remove field level access for the user. In UE/EE, removing it from the page layout does nothing to field-level security - this is controlled separately. This way you can report on fields (ie have access to them) without necessarily showing them on the page layout.

My class is defined without sharing. I don't think sharing makes a difference at field level visibilty. It is record level visibility. I am not trying to see if a specific record is visible. I want to see if a field is visible to the user.


On accessibility, I am just saying there is no definition of accessiblity other than then EE edition access in UI. Somewhere it should be defined. And it means different things in API and EE Edition UI.