Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Boolean Class
Namespace
Boolean Methods
The following are methods for Boolean. All methods are static.
valueOf(stringToBoolean)
Signature
public static Boolean valueOf(String stringToBoolean)
Parameters
- stringToBoolean: Type: String
Return Value
Type: Boolean
Usage
If the specified argument is null, this method throws an exception.
Example
1Boolean b = Boolean.valueOf('true');
2System.assertEquals(true, b);valueOf(fieldValue)
Signature
public static Boolean valueOf(Object fieldValue)
Parameters
- fieldValue: Type: Object
Return Value
Type: Boolean
Usage
Use this method with the OldValue or NewValue fields of history sObjects, such as AccountHistory, when the field type corresponds to a Boolean type, like a checkbox field.
Example
1List<AccountHistory> ahlist =
2 [SELECT Field,OldValue,NewValue FROM AccountHistory];
3for(AccountHistory ah : ahlist) {
4 System.debug('Field: ' + ah.Field);
5 if (ah.field == 'IsPlatinum__c') {
6 Boolean oldValue = Boolean.valueOf(ah.OldValue);
7 Boolean newValue = Boolean.valueOf(ah.NewValue);
8 }
9}