getListOfFields
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 static Map<String,Object> getListOfFields(String sobjectType){ | |
SObjectType objectType = Schema.getGlobalDescribe().get(sobjectType); | |
Map<String,Schema.SObjectField> mapObjectFields = objectType.getDescribe().fields.getMap(); | |
Map<String,Object> fieldMap = new Map<String,Object>(); | |
List<String> fieldNames = new List<String>(); | |
for (String field : mapObjectFields.keySet()) { | |
Schema.DescribeFieldResult dr = mapObjectFields.get(field).getDescribe(); | |
//Only add Custom, non-formula fields, non-auto number | |
if (dr.isCustom() && !dr.isCalculated() && !dr.isAutoNumber()) { | |
fieldNames.add(field); | |
fieldMap.put(field,null); | |
} else if (dr.isCreateable()) { | |
fieldNames.add(field); | |
fieldMap.put(field,null); | |
} | |
} | |
return fieldMap; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment