+ Start a Discussion
Rakesh ChattyRakesh Chatty 

Invalid field for SObject Account


Im trying to get editable fields and non editable fields and use them to iterate in visualforce using apex:repeat.

readOnlyFields   = new List<SObjectField>();
        accessableFields = new List<SObjectField>();
        for(SObjectField field :sObjectType.Account.fields.getMap().values()){
            if(field.getDescribe().isAccessible() && !field.getDescribe().isUpdateable() && !field.getDescribe().isCreateable()){
                nonEditableFields +=field + ',';
                editableFields +=field + ',';

Vf Code:

<apex:repeat value="{!accessableFields}" var="a">

selectedList1 is an account type which contains account information.

can some one hep me to  avoid this error.
Error: Invalid field  for SObject Account

Thank you.
ShirishaShirisha (Salesforce Developers) 
Hi Rakesh,


I would suggest you to add the system.debug() statements to print the list of Editable or non Editable fields on the VF page.Please enable the debug logs and check the list of fields to see,if it is returning the fields which are not related to Account.


Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
Please check the logs and see for which field you are getting the error message.