+ Start a Discussion

Help with sObject construction

When constructing an sObject for example:


Account a = new Account(Name = 'Test Account ', Description = 'Some Description');

How do I know if a field's value should be encapsulated in quotes? (is this documented in the APEX or Metadata guides by chance?)


I believe an sObject can be of the following types, but not sure which ones would require quotes and which ones would not require quotes for the values when constructing the sObject:


  • base64
  • boolean
  • combobox
  • currency
  • date
  • datetime
  • double
  • email
  • encryptedstring
  • id
  • integer
  • multipicklist
  • percent
  • phone
  • picklist
  • string
  • reference
  • textarea
  • time
  • url
Anup JadhavAnup Jadhav

The rule is very simple, if the field type is text or string or textarea, encapsulate the value in quotes.  


Any field type that kinda stores a string value needs to be in quotes.


- Anup