> For the complete documentation index, see [llms.txt](https://docs.work-relay.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.work-relay.com/automations/functions-and-formulas/functions-library/logical-functions.md).

# Logical functions

<details>

<summary>ISBLANK</summary>

Analyzes the given expression and returns:

* With one argument: boolean value (**true** if argument expression does not have a value (is empty or does not exist), otherwise returns **false**).
* With 2 or 3 arguments: some expression evaluation result.

**Usage:**

{% code overflow="wrap" %}

```apex
ISBLANK(parameter)
ISBLANK(parameter1, if_true_parameter2)
ISBLANK(parameter1, if_true_parameter2, if_false_parameter3)
```

{% endcode %}

*<mark style="color:cyan;">Replace the parameters with the expressions to evaluate.</mark>*

**Example 1:**

{% code overflow="wrap" %}

```apex
ISBLANK({$Variables.someDate})
```

{% endcode %}

Returns **true** if variable "someDate" value is empty (or this variable does not exist at all), and **false** if it has a value.

**Example 2:**

{% code overflow="wrap" %}

```apex
ISBLANK({$Variables.someDate}, '{$System.date}') 
```

{% endcode %}

Returns current system date if variable "someDate" value is empty (or this variable does not exist at all), and variable value in other case.

**Example 3:**

{% code overflow="wrap" %}

```apex
ISBLANK({$Variables.someDate}, '{$System.date}', '{Opportunity.closeDate}') 
```

{% endcode %}

Returns current system date if variable "someDate" value is empty (or this variable does not exist at all), and value of {Opportunity.closeDate} field if variable has a value.

</details>

<details>

<summary>NOT</summary>

Returns **false** for TRUE and **true** for FALSE (inverts result of logical expression).

**Usage:**

```apex
NOT(parameter)
```

*<mark style="color:cyan;">Replace</mark>* *<mark style="color:cyan;">`parameter`</mark>* *<mark style="color:cyan;">with the expression to evaluate.</mark>*

**Example:**

```apex
NOT(CONTAINS({Opportunity.Product_Type__c}, 'part'))
```

Returns **true** when the product type contains 'part'.

</details>

<details>

<summary>IF</summary>

Determines if expressions are true or false. Returns a given value if true and another value if false.

**Usage:**

```apex
IF(condition, result_if_true, result_if_false)
```

*<mark style="color:cyan;">Replace</mark>* *<mark style="color:cyan;">`condition`</mark>* *<mark style="color:cyan;">with the expression to evaluate.</mark>*

{% hint style="warning" %}
Condition must return boolean (true or false) result.
{% endhint %}

**Example:**

{% code overflow="wrap" %}

```apex
IF({Opportunity.Items_Number__c} >0, 'In Progress', 'Pending')
```

{% endcode %}

Returns **'In Progress'** when the number of items exceeds zero. Otherwise, returns **'Pending'**.

</details>

<details>

<summary>AND</summary>

Returns boolean response: **true** if all parameter values are true, and **false** if one or more values are false.

**Usage:**

{% code overflow="wrap" %}

```apex
AND(boolean_parameter1, boolean_parameter2, ...)
```

{% endcode %}

*<mark style="color:cyan;">Replace the parameters with values or expressions to evaluate.</mark>*

**Example:**

{% code overflow="wrap" %}

```apex
AND({Contact.Migrated__c} = 'Yes', {Contact.Trusted__c} = 'Yes')
```

{% endcode %}

Returns **true** when both values equal 'Yes'. Otherwise, returns **false**.

</details>

<details>

<summary>OR</summary>

Returns boolean value: **true** if at least one parameter is true, and **false** if all parameters are false.

**Usage:**

{% code overflow="wrap" %}

```apex
OR(boolean_parameter1, boolean_parameter2, ...)
```

{% endcode %}

*<mark style="color:cyan;">Replace the parameters with values or expressions to evaluate.</mark>*

**Example:**

{% code overflow="wrap" %}

```apex
OR({$Variables.Exhibition_month__c} = 'MAR', {Partner__c.Exhibition_month__c} = 'APR', {Partner__c.Exhibition_month__c} = 'MAY')
```

{% endcode %}

Returns **true** when `Exhibition_month__c` is set to a spring month.

</details>

<details>

<summary>CASE</summary>

Checks given expression value against series of case values. If the expression is equal to one of the case values, returns the corresponding result.

**Usage**:

{% code overflow="wrap" %}

```apex
CASE(value, case1, result1, case2, result2, ..., else_result) 
```

{% endcode %}

*<mark style="color:cyan;">Replace:</mark>*

* *<mark style="color:cyan;">`value`</mark>* *<mark style="color:cyan;">with the field or value you want compared to each specified</mark>* *<mark style="color:cyan;">`case`</mark>*
* *<mark style="color:cyan;">each</mark>* *<mark style="color:cyan;">`case`</mark>* *<mark style="color:cyan;">with the data/expression/field for comparison</mark>*
* *<mark style="color:cyan;">each</mark>* *<mark style="color:cyan;">`result`</mark>* *<mark style="color:cyan;">with data/expression/field that must be returned for the proper case</mark>*
* *<mark style="color:cyan;">`else_result`</mark>* *<mark style="color:cyan;">with the data/expression/field that must be returned when the expression does not equal any case</mark>*

**Example:**

<mark style="color:orange;">Let String\_\_c = 'Plane'.</mark>

{% code overflow="wrap" %}

```apex
CASE({Stub__c.String__c}, 'Car' , 'drive', 'Plane', 'fly', 'Boat', 'sail', 'none') 
```

{% endcode %}

Returns '**fly**'.

</details>

<details>

<summary>IN</summary>

Returns boolean (**true** or **false**) result depending on whether checked value is present in the given list.

**Usage:**

{% code overflow="wrap" %}

```apex
IN(value, list_of_values OR [value1, value2, ...])
```

{% endcode %}

*<mark style="color:cyan;">Replace:</mark>*

* *<mark style="color:cyan;">`value`</mark>* *<mark style="color:cyan;">with value you need to check in list</mark>*
* *<mark style="color:cyan;">`list_of_values`</mark>* *<mark style="color:cyan;">with the list to compare value parameter to; or pass list values as separate parameters</mark>* *<mark style="color:cyan;">`value1`</mark><mark style="color:cyan;">,</mark>* *<mark style="color:cyan;">`value2`</mark><mark style="color:cyan;">, etc</mark>*

{% hint style="info" %}
You can also pass combination of lists and separate values as parameters.
{% endhint %}

**Example 1:**

{% code overflow="wrap" %}

```apex
IN({Opportunity.Stage}, 'Closed Lost', 'Closed Won', 'Negotiation/Review', 'Needs Analysis') 
```

{% endcode %}

Returns **true** if Opportunity.Stage field value is present in the given set of strings and **false** if it is not.

**Example 2:**

<mark style="color:orange;">Let Stub\_\_c.String\_\_c = '\["YESTERDAY", "NOW", "TOMORROW"]'.</mark>

{% code overflow="wrap" %}

```apex
IN('NOW', JPARSE({Stub__c.String__c})) 
```

{% endcode %}

Returns **true**.

**Example 3:**

<mark style="color:orange;">Let Stub\_\_c.String\_\_c = '\["YESTERDAY", "NOW", "TOMORROW"]' and Stub\_\_c.Area\_\_c = 'NEXT YEAR'.</mark>

{% code overflow="wrap" %}

```apex
IN('NEXT YEAR', JPARSE({Stub__c.String__c}), {Stub__c.Area__c}, 'PREVIOUS YEAR')
```

{% endcode %}

Returns **true**.

</details>

<details>

<summary>NOTIN</summary>

Returns boolean (**true** or **false**) result depending on whether checked value is NOT present in given list.\
\
**Usage:**

{% code overflow="wrap" %}

```apex
NOTIN(value, list_of_values OR [value1, value2, ...])
```

{% endcode %}

*<mark style="color:cyan;">Replace:</mark>*

* *<mark style="color:cyan;">`value`</mark>* *<mark style="color:cyan;">with value you need to check in list</mark>*
* *<mark style="color:cyan;">`list_of_values`</mark>* *<mark style="color:cyan;">with the list to compare value parameter to; or pass list values as separate parameters</mark>* *<mark style="color:cyan;">`value1`</mark><mark style="color:cyan;">,</mark>* *<mark style="color:cyan;">`value2`</mark><mark style="color:cyan;">, etc.</mark>*

{% hint style="info" %}
You can also pass combination of lists and separate values as parameters.
{% endhint %}

**Example 1:**

{% code overflow="wrap" %}

```apex
IN({Opportunity.Stage}, 'Closed Lost', 'Closed Won', 'Negotiation/Review', 'Needs Analysis') 
```

{% endcode %}

Returns **true** if Opportunity.Stage field value is not present in the given set of strings and **false** if it is.

**Example 2:**

<mark style="color:orange;">Let Stub\_\_c.String\_\_c = '\["YESTERDAY", "NOW", "TOMORROW"]'.</mark>

{% code overflow="wrap" %}

```apex
NOTIN('NOW', JPARSE({Stub__c.String__c})) 
```

{% endcode %}

Returns **false**.

**Example 3:**

<mark style="color:orange;">Let Stub\_\_c.String\_\_c = '\["YESTERDAY", "NOW", "TOMORROW"]' and Stub\_\_c.Area\_\_c = 'NEXT YEAR'.</mark>

{% code overflow="wrap" %}

```apex
NOTIN('NEXT MONTH', JPARSE({Stub__c.String__c}), {Stub__c.Area__c}, 'PREVIOUS YEAR') 
```

{% endcode %}

Returns **true**.

</details>

<details>

<summary>INSTANCEOF</summary>

Validates if specified value is an instance of a declared type. Returns boolean result (**true** or **false**).

**Usage:**

{% code overflow="wrap" %}

```apex
INSTANCEOF(value, Decimal|Boolean|String|Date|DateTime)
```

{% endcode %}

*<mark style="color:cyan;">Replace</mark>* *<mark style="color:cyan;">`value`</mark>* *<mark style="color:cyan;">argument with a value you want to validate.</mark>*\
*<mark style="color:cyan;">Pass one of the allowed types (Decimal, Boolean, String, Date or DateTime) as second argument.</mark>*

**Example:**

{% code overflow="wrap" %}

```apex
INSTANCEOF({$Variables.Result}, Decimal) 
```

{% endcode %}

Returns **true** if variable "Result" is a number, and **false** if it is not.

</details>
