0

I am trying to do get values from the object using string key, I have typecast the Contact object into the object but not getting value. Please help how to get value from the object using string API filed

List<String> lstfiedName = new List<String>{'LastName','Email','Phone'};     
for(Contact objContact : lstofContact){
 object obj = (object)objContact;
  for(String fielName : lstfiedName){
      System.debug('lastname::'+obj.get(fiedName));
  }
}

Getting Error : Method does not exist or incorrect signature: void get(String) from the type Object

1 Answer 1

5

try with sObject instead of Contact since get and set methods are available in sObject class. Replace your Contact objContact with sObject objContact in for loop. Also, try without Object obj as it should work fine without casting it to Object type

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .