Class BooleanCondition Stay organized with collections Save and categorize content based on your preferences.
Page Summary
A
BooleanConditionis accessed withinConditionalFormatRulesand each rule can have one boolean condition.A boolean condition contains a boolean criteria and formatting settings that are applied if the criteria evaluates to true for a cell.
Methods are available to retrieve the background color, font color, bold, italic, strikethrough, and underline settings of a boolean condition.
Methods also exist to retrieve the criteria type and criteria values of a boolean condition.
Some methods for getting background and font color strings are deprecated and replaced by methods that return
Colorobjects.
Access boolean conditions inConditional. Eachconditional format rule may contain a single boolean condition. The boolean condition itselfcontains a boolean criteria (with values) and formatting settings. The criteria is evaluatedagainst the content of a cell resulting in either atrue orfalse value. If thecriteria evaluates totrue, the condition's formatting settings are applied to the cell.
Methods
| Method | Return type | Brief description |
|---|---|---|
get | Color|null | Gets the background color for this boolean condition. |
get | Boolean|null | Returnstrue if this boolean condition bolds the text and returnsfalse if thisboolean condition removes bolding from the text. |
get | Boolean | Gets the rule's criteria type as defined in theBoolean enum. |
get | Object[] | Gets an array of arguments for the rule's criteria. |
get | Color|null | Gets the font color for this boolean condition. |
get | Boolean|null | Returnstrue if this boolean condition italicises the text and returnsfalse ifthis boolean condition removes italics from the text. |
get | Boolean|null | Returnstrue if this boolean condition strikes through the text and returnsfalse if this boolean condition removes strikethrough from the text. |
get | Boolean|null | Returnstrue if this boolean condition underlines the text and returnsfalse ifthis boolean condition removes underlining from the text. |
Deprecated methods
| Method | Return type | Brief description |
|---|---|---|
| String|null | Gets the background color string for this boolean condition. |
| String|null | Gets the font color string for this boolean condition. |
Detailed documentation
getBackgroundObject()
Gets the background color for this boolean condition. Returnsnull if not set.
// Logs the boolean condition background color for each conditional format rule// on a sheet.constsheet=SpreadsheetApp.getActiveSheet();construles=sheet.getConditionalFormatRules();for(construleofrules){constcolor=rule.getBooleanCondition().getBackgroundObject();Logger.log(`Background color:${color.asRgbColor().asHexString()}`);}
Return
Color|null — The background color, ornull if not set for this condition.
getBold()
Returnstrue if this boolean condition bolds the text and returnsfalse if thisboolean condition removes bolding from the text. Returnsnull if bolding is unaffected.
// Logs the boolean condition font weight for each conditional format rule on a// sheet.constsheet=SpreadsheetApp.getActiveSheet();construles=sheet.getConditionalFormatRules();for(construleofrules){constbold=rule.getBooleanCondition().getBold();Logger.log(`Bold:${bold}`);}
Return
Boolean|null — whether or not the boolean condition bolds the text, ornull if bolding is unaffected
getCriteriaType()
Gets the rule's criteria type as defined in theBoolean enum. To get thearguments for the criteria, useget. To use these values to create ormodify a conditional formatting rule, seeConditional.
// Log information about the conditional formats on the active sheet that use// boolean conditions.constformats=SpreadsheetApp.getActiveSheet.getConditionalFormats();SpreadsheetApp.getActiveSheet.getConditionalFormats().forEach((format)=>{constbooleanCondition=format.getBooleanCondition();if(booleanCondition){constcriteria=booleanCondition.getCriteriaType();constargs=booleanCondition.getCriteriaValues();Logger.log(`The conditional format rule is${criteria}${args}`);}});
Return
Boolean — The type of conditional formatting criteria.
getCriteriaValues()
Gets an array of arguments for the rule's criteria. To get the criteria type, useget. To use these values to create or modify a conditional formatting rule, seeConditional.
// Log information about the conditional formats on the active sheet that use// boolean conditions.constformats=SpreadsheetApp.getActiveSheet.getConditionalFormats();SpreadsheetApp.getActiveSheet.getConditionalFormats().forEach((format)=>{constbooleanCondition=format.getBooleanCondition();if(booleanCondition){constcriteria=booleanCondition.getCriteriaType();constargs=booleanCondition.getCriteriaValues();Logger.log(`The conditional format rule is${criteria}${args}`);}});
Return
Object[] — An array of arguments appropriate to the rule's criteria type; the number of arguments and their type match the correspondingwhen...() method of theConditional class.
getFontColorObject()
Gets the font color for this boolean condition. Returnsnull if not set.
// Logs the boolean condition font color for each conditional format rule on a// sheet.constsheet=SpreadsheetApp.getActiveSheet();construles=sheet.getConditionalFormatRules();for(construleofrules){constcolor=rule.getBooleanCondition().getFontColorObject();Logger.log(`Font color:${color.asRgbColor().asHexString()}`);}
Return
Color|null — The font color, ornull if not set for this condition.
getItalic()
Returnstrue if this boolean condition italicises the text and returnsfalse ifthis boolean condition removes italics from the text. Returnsnull if italics areunaffected.
// Logs the boolean condition font style for each conditional format rule on a// sheet.constsheet=SpreadsheetApp.getActiveSheet();construles=sheet.getConditionalFormatRules();for(construleofrules){constitalic=rule.getBooleanCondition().getItalic();Logger.log(`Italic:${italic}`);}
Return
Boolean|null — whether or not the boolean condition italicises the text, ornull if italicising is unaffected
getStrikethrough()
Returnstrue if this boolean condition strikes through the text and returnsfalse if this boolean condition removes strikethrough from the text. Returnsnull ifstrikethrough is unaffected.
// Logs the boolean condition strikethrough setting for each conditional format// rule on a sheet.constsheet=SpreadsheetApp.getActiveSheet();construles=sheet.getConditionalFormatRules();for(construleofrules){conststrikethrough=rule.getBooleanCondition().getStrikethrough();Logger.log(`Strikethrough:${strikethrough}`);}
Return
Boolean|null — whether or not the boolean condition strikes through the text, ornull if strikethrough is unaffected
getUnderline()
Returnstrue if this boolean condition underlines the text and returnsfalse ifthis boolean condition removes underlining from the text. Returnsnull if underliningis unaffected.
// Logs the boolean condition underline setting for each conditional format rule// on a sheet.constsheet=SpreadsheetApp.getActiveSheet();construles=sheet.getConditionalFormatRules();for(construleofrules){constunderline=rule.getBooleanCondition().getUnderline();Logger.log(`Underline:${underline}`);}
Return
Boolean|null — whether or not the boolean condition underlines the text, ornull if underlining is unaffected
Deprecated methods
getBackground()
getBackground() Deprecated. Replaced byget
Gets the background color string for this boolean condition. Returnsnull if not set.
// Logs the boolean condition background color for each conditional format rule// on a sheet.constsheet=SpreadsheetApp.getActiveSheet();construles=sheet.getConditionalFormatRules();for(construleofrules){constcolor=rule.getBooleanCondition().getBackground();Logger.log(`Background color:${color}`);}
Return
String|null — The background color string, ornull if not set for this condition.
getFontColor()
getFontColor() Deprecated. Replaced byget
Gets the font color string for this boolean condition. Returnsnull if not set.
// Logs the boolean condition font color for each conditional format rule on a// sheet.constsheet=SpreadsheetApp.getActiveSheet();construles=sheet.getConditionalFormatRules();for(construleofrules){Logger.log(`Font color:${rule.getBooleanCondition().getFontColor()}`);}
Return
String|null — The font color string, ornull if not set for this condition.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-11 UTC.