Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

What are the standard values for boolean datatype? I have two columns like below in different tables. One table has values like 0 and 1 and the other table has true and false. I need this to set a standard datatype in my target table in Teradata. Teradata does not support Boolean. I have to set BYTEINT or VARCHAR.

autoNumber: false
byteLength: 0
calculated: false
caseSensitive: false
createable: false
custom: true
defaultedOnCreate: true
deprecatedAndHidden: false
digits: 0
filterable: true
groupable: true
idLookup: false
label: IsActive
length: 0
name: IsActive__c
nameField: false
namePointing: false
nillable: false
permissionable: true
precision: 0
restrictedPicklist: false
scale: 0
soapType: xsd:boolean
sortable: true
type: boolean
unique: false
updateable: false
share|improve this question

2 Answers 2

up vote 7 down vote accepted

A Boolean should always return a true, false, or null. According to the Apex docs, a Boolean is:

A value that can only be assigned true, false, or null. For example:

Boolean isWinner = true;

It also states:

Apex uses the same primitive data types as the SOAP API. All primitive data types are passed by value.

The odd thing is, in the SOAP API docs a Boolean is defined as:

Boolean fields have one of these values: true (or 1), or false (or 0).

So, it turns out the fields aren't actually the same as the Apex Docs state. The SOAP API doesn't appear to support null and it doesn't have anything specified on which fields will return true and which will return 1.


My suggestion would be to simply perform some logic and store everything as 1s and 0s or true and false. Just pick which one you want to go with and manipulate the data as you are pulling it out of Salesforce. I did some quick searching and there doesn't seem to be a list of fields anywhere that specify which are returned as either.

share|improve this answer

true, false and FILE_NOT_FOUND, duh ;) (jokes aside, I've upvoted Jesse's answer too)

For what it's worth - "export report detail" always shows 0/1 for columns of type checkbox - so sometimes it's easier to use when users export some data, mass edit it in Excel and give it back to you to upload fixes. I usually go with numerics also because it's sometimes convenient to get "all records" and "records where X = true" as simple summaries in the reports / queries.

Also the compatibility with SOAP specs (so no need to use any mapping logic) is tempting...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.