Created
July 7, 2019 15:26
-
-
Save sfmishra/713820024b9e0f8880edd377690bc95d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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