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
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
A Boolean should always return a
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.
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…
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0