You need to sign in to do that
Don't have an account?
Tobias Hagge
apex:repeat all fields from Object
Hello.
I would like to render all fields in a VF page and I think the repeat function might be the easiest.
Thanks!
I would like to render all fields in a VF page and I think the repeat function might be the easiest.
<apex:repeat value="{!$ObjectType.Account.Fields.}" var="f"> <apex:outputfield value="{!Account[f]}"> </apex:outputfield> </apex:repeat>I am missing the last bit though. Is that achievable, or would it need a class that gets all fields and then the repeat function referencing it?
Thanks!
setup>customize>account>fieldset>new>
give the name and description
and drag fields that you want and save it.
Then write thiscode
<apex:repeat value="{!$ObjectType.task.Account.fieldsetname}" var="f">
<apex:inputfield value="{!Account[f]}" />
</apex:repeat>
Will work
I suggest you to create a field set in account and add all the fields that you want to use in this VF.
Then this is the code of your VF
<apex:page>
<apex:repeat value="{!$ObjectType.Account.FieldSets.FieldSetName}" var="f">
<apex:outputText>{!f.Label}</apex:outputText>
</apex:repeat>
</apex:page>
Hope this helps
Jerome
SObjectType accountType = Schema.getGlobalDescribe().get('Account');
Map<String,Schema.SObjectField> mfields = accountType.getDescribe().fields.getMap();
Jerome
Account_ID__c is a custom formula field. I assume that the function has a general problem with formula fields? Is there a good way to exclude the formula field type from the expression?
Thanks
what do you want to display in your VF in the end ? the list of fields of Account Object ?
List<String> AccountFields {get; set;}
AccountFields = new List<String>();
Map<String, Schema.SObjectField> schemaFieldMap = Schema.SObjectType.Account.fields.getMap();
for(String MyFieldName : schemaFieldMap.keyset()){
AccountFields.add(MyFieldName);
}
then you use this list in you VF, with
<apex:repeat value="{!AccountFields}" var="field">
<apex:outputText value="{!field}"/><br></br>
</apex:repeat>
Jerome