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
DannyK89DannyK89 

get() method

I would like to know how one would use the get() method attached to Objects. It seems like something that I might want to use. 

Best Answer chosen by Admin (Salesforce Developers) 
hemantgarghemantgarg

get() method is used to fetch the value of a column in a record like following :-

 

Account ac = [select Id,Name from account where Id=:<your id>];

string accName = ac.get('Name'); // This can be done simply accName = ac.Name

 

It depends on requirement , for example if you want to create a table with query results dynamically, then this method helps you lot.