Skip to content

Instantly share code, notes, and snippets.

@sfmishra
Created July 7, 2019 15:26
Show Gist options
  • Save sfmishra/713820024b9e0f8880edd377690bc95d to your computer and use it in GitHub Desktop.
Save sfmishra/713820024b9e0f8880edd377690bc95d to your computer and use it in GitHub Desktop.
public with sharing class SObjectHelper {
public static Object getRelatedFieldValue(sObject obj, String fieldName) {
if(fieldName.contains('.')){
String relation = fieldName.substringBefore('.');
String relatedField = fieldName.substringAfter('.');
return SObjectHelper.getRelatedFieldValue((sObject)obj.getSObject(relation), relatedField);
} else {
return obj.get(fieldName);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment