-
-
Save krystiancharubin/597771a8e1c2de61584f 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
global static String getSOQL(String objectTypeName, List < String > fieldList) { | |
List < String > conditionals = new List < String > (); | |
for (String field: fieldList) conditionals.add(field + ' != null'); | |
String soql = 'SELECT {!fieldList} FROM {!objectTypeName} WHERE {!conditionals}'; | |
return soql | |
.replace('{!fieldList}', String.join(fieldList, ',')) | |
.replace('{!objectTypeName}', objectTypeName) | |
.replace('{!conditionals}', String.join(conditionals, ' OR ')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment