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){

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


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.