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
Saurabh SmartySaurabh Smarty 

Hi All, I need to display all the fileds of an objects in the VF Page so that if anyone adds/deletes a field it should be reflected in the VF page automatically

I have an idea that we can use getdescribeField method of schema class and arranging it in map through getMap() method but not sure how ll it be actually implemented.

Thanks in Advance!
jigarshahjigarshah
You can create a Field Set and refer the field set to display the fields using apex:repeat within your Visualforce Page. Thus, if the field set is modified and a field is removed, it will be automatically excluded from the Visualforce page.

Refer the following link from the Visualforce developer Guide which provides details around using Field Sets within Visualforce - https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_dynamic_vf_field_sets.htm.

Please mark this thread as SOLVED and answer as the BEST ANSWER if it helps address your issue.
Anant Agarwal 15Anant Agarwal 15
Hi Saurav,

Yes, you are correct you have to use the fields.getMap(). You may refer the below code for your reference - 
public static Set<String> accountObjFieldSet = new Set<String>();
accountObjFieldSet = Schema.SObjectType.Account.fields.getMap().keySet();
You will have to replace Account with the object API name you want to use and then you can use <apex:repeat> tag in a Visualforce page on the accountObjFieldSet .

Hope this will resolve your query :)