Use Of addFields in ApexPages.StandardController

The add fields method helps developers specify fields for the standard controller to query in Visualforce pages.


public AccountController(ApexPages.StandardController stdController){

            this.controller = stdController;

            List<String> fieldNamesList = new List<String>{Type,Industry};

            stdController.addFields(fieldNamesList); 

           //stdController.addFields(new List<String>{'Name', 'TaxExemption__c', 'Industry'});

}


Reference:

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/apex_ApexPages_StandardController_addFields.htm

Comments

Popular posts from this blog

Introduction to Salesforce Agent Script: Build Predictable AI Agents

Anti-Patterns in Salesforce Agentforce: What to Avoid When Building AI Agents

MCP vs. Traditional APIs: Choosing the Right Integration Approach