No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
Newer Version Available
Boolean Class
Contains methods for the Boolean primitive data type.
Namespace
Boolean Methods
The following are methods for Boolean. All methods are static.
valueOf(String)
Converts the specified string to a Boolean value and returns true if the specified string value
is true. Otherwise, returns false.
Signature
public static Boolean valueOf(String toBoolean)
Parameters
- toBoolean
- 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(Object)
Converts the specified history tracking field value to
a Boolean value.
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:
Example
1List<AccountHistory> ahlist =
2 [SELECT Field,OldValue,NewValue
3 FROM AccountHistory];
4for(AccountHistory ah : ahlist) {
5 System.debug('Field: ' + ah.Field);
6 if (ah.field == 'IsPlatinum__c') {
7 Boolean oldValue =
8 Boolean.valueOf(ah.OldValue);
9 Boolean newValue =
10 Boolean.valueOf(ah.NewValue);
11}