Skip to content

Instantly share code, notes, and snippets.

@gitmatheus
Created March 24, 2022 23:59
Show Gist options
  • Save gitmatheus/a57e65ee19826cb1d8d55b5ac9df538e to your computer and use it in GitHub Desktop.
Save gitmatheus/a57e65ee19826cb1d8d55b5ac9df538e to your computer and use it in GitHub Desktop.
public class FieldReader implements IFieldReader {
// Retrieves a value from a field, as an object
public Object getFieldValue(SObject record, String fieldName) {
return record.get(fieldName);
}
// Retrieves a value from a field, as a SObject
public SObject getFieldRecord(SObject record, String fieldName) {
return record.getSObject(fieldName);
}
// Retrieves a value from a field, as a List of SObject
public List<SObject> getFieldRecords(SObject record, String fieldName) {
return record.getSObjects(fieldName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment