lib/databasedotcom/sobject/sobject.rb in databasedotcom-ejholmes-1.3.2 vs lib/databasedotcom/sobject/sobject.rb in databasedotcom-ejholmes-1.3.3
- old
+ new
@@ -12,10 +12,14 @@
# Returns a new Sobject. The default values for all attributes are set based on its description.
def initialize(attrs = {})
super()
self.class.description["fields"].each do |field|
- self.send("#{field["name"]}=", field["defaultValueFormula"])
+ if field['type'] =~ /(picklist|multipicklist)/ && picklist_option = field['picklistValues'].find { |p| p['defaultValue'] }
+ self.send("#{field["name"]}=", picklist_option['value'])
+ else
+ self.send("#{field["name"]}=", field["defaultValueFormula"])
+ end
end
self.attributes=(attrs)
end
# Returns a hash representing the state of this object