Share

Check if the Field is Boolean

Definition: isBoolean(fieldname: str) → bool
Description: Checks if a specific field contains a boolean data type value. The return value can be further used to transform the data. For example, setting the account exists field to Yes.
Parameters: fieldname: The name of the field whose value is to be checked.
Returns: True, if the specified field’s value is of type, boolean.
False, for null and non-boolean values.

The following script checks if the specified property is a boolean:

from io.hevo.api import Event

def transform(event):
    <existing_properties> = event.getProperties()

    <boolean_value_type> = event.isBoolean('<property_name>')

    return event

Sample Transformation

The following script checks if the property named available is a boolean. The isBoolean property displays the return value of the method:

from io.hevo.api import Event

def transform(event):
    properties = event.getProperties()

    # Check if the 'available' field is Boolean
    if event.isBoolean('available'):
        properties['isBoolean'] = 'Yes'

    return event

Sample Output

The Transformation sets the isBoolean property to Yes, as the available property is boolean.

Is a Boolean


Last updated on Jun 30, 2023

Tell us what went wrong

Skip to the section