Created
January 29, 2023 16:28
-
-
Save tehnrd/eea95073ea54fed7a2b8dc0c45634cae to your computer and use it in GitHub Desktop.
Apex SOQL only Createable Fields
This file contains hidden or 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
List<Schema.SObjectField> flds = Schema.sObjectType.Lead.fields.getmap().values(); | |
List<String> selectFields = new List<String>(); | |
for (Schema.SObjectField fld : flds) { | |
Schema.DescribeFieldResult fldDesc = fld.getDescribe(); | |
if (fldDesc.isCreateable() == true) { | |
selectFields.add(fldDesc.getName()); | |
} | |
} | |
String soql = 'SELECT ' + String.join(selectFields, ',') + ' FROM Lead'; | |
system.debug(soql); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment