+ Start a Discussion

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) 

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.