Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
sendWrittenFields
public static Map<String,Object> sendWrittenFields(sObject record){
Map<String, Object> fieldsToValue = record.getPopulatedFieldsAsMap();
Map<String,Object> fieldMap = new Map<String,Object>();
fieldMap.putAll(fieldsToValue);
List<String> fieldsToRemove = new List<String>();
fieldsToRemove.add('Id');
fieldsToRemove.add('OwnerId');
fieldsToRemove.add('id');
fieldsToRemove.add('ownerid');
//Always remove Id
for (String s : fieldsToRemove) {
fieldMap.remove(s);
}
return fieldMap;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.