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
Rakesh ChattyRakesh Chatty 

Invalid field for SObject Account

Hi,

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

Apex:code
 
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()){
                readOnlyFields.add(field);
                nonEditableFields +=field + ',';
            }else{
                accessableFields.add(field);
                editableFields +=field + ',';
            }
        }



Vf Code:

 
<apex:repeat value="{!accessableFields}" var="a">
    <tr><td>{!selectedList1.[a]}</td></tr>
    </apex:repeat>



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,

Greetings!

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.

https://help.salesforce.com/apex/HTViewHelpDoc?id=code_add_users_debug_log.htm&language=en_us

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

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