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
Matthew BirckbichlerMatthew Birckbichler 

visualforce field name selector

I want to create a visual force page that has dependent picklists to show all fields and related objects fields. Basically I want it to function exactly like the 'insert field' button in a formula builder or process builder. The end goal is to just be able to navigate through an objects fields/related fields and copy the api name of the selected field. Can anybody help me with code for this, and if you have the time please explain a little bit. Thanks
Best Answer chosen by Matthew Birckbichler
pconpcon
This is not something that anyone is going to write the code for you for this.  I can point you in the right direction.  This is going to be a non-trivial thing to do.  You will want to understand how the Schema [1] methods work particularly the describeSObjects method [2] and the  DescribeFieldResult class.  I would create a bunch of maps (and probably maps of maps) to generate your datastructure.  You will probably also want to create a wrapper class that holds your data to make it easier to both render the human readable field name and keep track of the API name.  I'd also recommend reading over this [4] article on how to interact with the Apex describe information.

[1] https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_schema.htm
[2] https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_schema.htm#apex_System_Schema_describeSObjects
[3] https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_fields_describe.htm
[4] https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dynamic_describe_objects_understanding.htm