0

I am passing an sObject as the parameter to a function and when I print this object before and after passing to the function, both are different. The First debug have more fields and debug in function has less field in sObject.

for(Sobject record : recordsList){
    System.debug(record); //------------printing 5 fields with values
    System.debug(JSON.serialize(record)); //------------printing 5 fields with values
    System.debug(JSON.serialize(record.get('ContactFax'))); //------------giving me the field value
    Utility.processObject(record)

}


public static void processObject(Sobject record){
    System.debug(record); //------------printing 3 fields with values
    System.debug(JSON.serialize(record)); //------------printing 5 fields with values
    System.debug(JSON.serialize(record.get('ContactFax'))); //------------giving me error @ Invalid field ContactFax for Case @
}

Is this expected behaviour related to the sObject?

4
  • are those methods exist in the same class? Apr 3, 2019 at 10:58
  • They are in a different class. But even I place them in the same class nothing changes.
    – Eric
    Apr 3, 2019 at 10:59
  • did you check the Object name from SObject before and after passing the record? Apr 3, 2019 at 11:01
  • They are same record
    – Eric
    Apr 3, 2019 at 11:33

0

You must log in to answer this question.

Browse other questions tagged .