+ Start a Discussion
Lalitha Pavani Rallabandi 9Lalitha Pavani Rallabandi 9 

Display Editable fields of the respective objects

Hi,
My requirement is: I should create a VF page where it should display the editable fields of an object. I created a VF page where it is displaying the editable fields of an opportunity. I placed the VF page in the global action. When I click on the button, it is displaying the opportunity related to editable fields. My requirement is, If I place the same vf page in the lead object, it should display the lead-related editable fields and the same with rest of the objects. 

Here is the code to display the opportunity fields. Can someone please help me in order to do the same with other object using one apex controller and one vf page. 

Apex Controller:
public class ControllerClassName {
    
    public List<String> oppList { get;set; }
    
    public void displayOpp()  {
      
       Map<String, Schema.SObjectField> oppFields = Schema.getGlobalDescribe().get('Opportunity').getDescribe().fields.getMap();
        
        list<string> editableFields = new list<string> ();
        
        for(schema.SObjectField editfieds :oppFields.values()){
            
        schema.DescribeFieldResult fieldResult = editfieds.getDescribe();
            
            if(fieldResult.isUpdateable()){
                
                editableFields.add(fieldResult.getName());
                
                oppList = new List<String>(editableFields);
                
                system.debug('Fields:::'+oppList);
            }
        }

VF Page:
<apex:page controller="ControllerClassName" action="{!autoRun}" >
    <apex:form >
        <apex:pageblock >
            
            <apex:pageblockTable value="{!oppList}" var="opps" >
                <apex:column value="{!opps}"/>
            </apex:pageblockTable>
            
         </apex:pageblock>
    </apex:form>
</apex:page>

User-added imageHelp me the same with other sObjects 
ShirishaShirisha (Salesforce Developers) 
Hi Lalitha,

Greetings!

You can achieve this by assignig the dynamic value to the standaardController so that you can get the Object Id based on the prefix of the record Id.

Please check the below document for the idea on how to do it.

https://developer.salesforce.com/forums/?id=906F0000000Ah2WIAS

https://developer.salesforce.com/forums/?id=906F000000092PrIAI

Kindly let me know if it helps you and close your query by marking it as best answer so that it can help others in the future.

Warm Regards,
Shirisha Pathuri