function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Luan SantosLuan Santos 

How to know if a field from a fieldset is read-only?

Hello everyone,

I need to solve this:
I'm using a fieldset on a visualforce page and I need to know if some field is read-only for set some styleClass. I know that we have some properties from fields, but I don't know exactly which property to use for this. 

For example:

<apex:outputPanel rendered="{!field.type == 'reference'}">

Here I'm using the property 'type' to set some styleClass in the inputfield inside of the outputpanel, what I need know now is what property I have to use to know if the field is read-only.. for example {!field.readOnly} .. but we know that doesn't exists.

Can someone help me with this?

Jackson SegalaJackson Segala

Hello Luan,

 

i think what are you talking about, is the FieldSetMember, there is no information for that on this class, here is the documentation:

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_Schema_FieldSetMember.htm

Anybody knows where is the information where the field is ReadOnly or not?

Nitin ShyamnaniNitin Shyamnani
Hi Luan,

If Apex code we can check using this approch

Map<String, Schema.SObjectField> map = Schema.SObjectType.Custom.fields.getMap();
for(String fieldName : map.keySet()) {
         if(map.get(fieldName).getDescribe().isUpdateable()) {
                  // Code to use this field 
         }
}

Thanks,
Nitin