# Logical

## 1. ISBLANK

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 arguments: some expression evaluation result or first argument value.
* With 3 arguments: some expression evaluation result or some other expression evaluation result.

{% tabs %}
{% tab title="Usage" %}
`ISBLANK(parameter1)` or \
`ISBLANK(parameter1, if_true_parameter2)` or \
`ISBLANK(parameter1, if_true_parameter2, if_false_parameter3)`

Replace:

`parameter1` with logical expression you want to evaluate;

`if_true_parameter2` with the result you want to get when `parameter1` returns **true**;

`if_false_parameter3` with the result you want to get when `parameter1` returns **false**.
{% endtab %}

{% tab title="Example 1" %}
`ISBLANK({$Variables.someDate})` will return **true** if variable *someDate* value is empty (or this variable does not exist at all), and **false** if it has a value.&#x20;
{% endtab %}

{% tab title="Example 2" %}
`ISBLANK({$Variables.someDate}, '{$System.date}')` will return current system date if variable *someDate* value is empty (or this variable does not exist at all), and a value of this variable in other case.
{% endtab %}

{% tab title="Example 3" %}
`ISBLANK({$Variables.someDate}, '{$System.date}', '{Opportunity.closeDate}')` will return 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.
{% endtab %}
{% endtabs %}

## 2. NOT

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

{% tabs %}
{% tab title="Usage" %}
`NOT(parameter)`&#x20;

Replace `parameter` with a logical expression that you want to evaluate.
{% endtab %}

{% tab title="Example" %}
`NOT(CONTAINS({Opportunity.Product_Type__c}, 'part'))` will return **true** if *Product Type* value contains '*part*' string and **false** if it doesn't.
{% endtab %}
{% endtabs %}

## 3. IF

Determines if condition expression is true or false. Returns a given value if true and another value if false.

{% tabs %}
{% tab title="Usage" %}
`IF(condition, result_if_true, result_if_false)`&#x20;

Replace:\
`condition` with with the logical expression,\
`result_if_true` with the result you want to get if the `condition` is true,\
`result_if_false` with the result you want to get if the `condition` is false.
{% endtab %}

{% tab title="Example" %}
I`F({Opportunity.Items_Number__c} > 0, 'In Progress', 'Pending')` will return 'I**n Progress**' if number of items is more than *0*, and '**Pending**' in other case.
{% endtab %}
{% endtabs %}

## 4. AND

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

{% tabs %}
{% tab title="Usage" %}
`AND(boolean_parameter1, boolean_parameter2, ...)`&#x20;

Replace `boolean_parameter1`, `boolean_parameter2`, etc with values or expressions that you want evaluated.
{% endtab %}

{% tab title="Example" %}
`AND({Contact.Migrated__c} = 'Yes', {Contact.Trusted__c} = 'Yes')` will return **true** if both *Contact Migrated* and *Contact Trusted* values are equal to 'Yes'. Otherwise it will return **false**.
{% endtab %}
{% endtabs %}

## 5. OR

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

{% tabs %}
{% tab title="Usage" %}
`OR(boolean_parameter1, boolean_parameter2, ...)`

Replace `boolean_parameter1`, `boolean_parameter2`, etc with values or expressions you want evaluated.
{% endtab %}

{% tab title="Example" %}
`OR({$Variables.Exhibition_month__c} = 'MAR', {Partner__c.Exhibition_month__c} = 'APR', {Partner__c.Exhibition_month__c} = 'MAY')` - this formula will return **true** if *Exhibition\_month\_\_c* is set to any spring month, and **false** if it is set to any other value.
{% endtab %}
{% endtabs %}

## 6. CASE

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

{% tabs %}
{% tab title="Usage" %}
`CASE(value, case1, result1, case2, result2, ..., else_result)`&#x20;

Replace:

`value` with the field or value you want compared to each specified case;

each case (`case1`, `case2`, etc.) with the data/expression/field for comparison;

each result (`result1`, `result2`, etc.) with data/expression/field that must be returned for the proper case;

`else_result` with the data/expression/field that must be returned when the expression does not equal to any case.
{% endtab %}

{% tab title="Example" %}
Let *String\_\_c* = '**Plane**'.&#x20;

`CASE({Stub__c.String__c}, 'Car' , 'drive', 'Plane', 'fly', 'Boat', 'sail', 'none')` will return '**fly**'.
{% endtab %}
{% endtabs %}

## 7. IN

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

{% tabs %}
{% tab title="Usage" %}
`IN(value, list_of_values OR [value1, value2, ...])`&#x20;

Replace:

`value` with value you need to check in list;

`list_of_values` with the list to compare value parameter to (or pass list of values as separate parameters  `value1`, `value2`, etc).&#x20;

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

{% tab title="Example 1" %}
`IN({Opportunity.Stage}, 'Lost', 'Won', 'Review', 'Needs Analysis')` returns **true** if *Opportunity.Stage* field value is present in the given set of strings (`'Lost', 'Won', 'Review', 'Needs Analysis'`) and **false** if it is not.
{% endtab %}

{% tab title="Example 2" %}
Let *Stub\_\_c.String\_\_c* = '**\["YESTERDAY", "NOW", "TOMORROW"]**'.

`IN('NOW', JPARSE({Stub__c.String__c}))` will return **true**.
{% endtab %}

{% tab title="Example 3" %}
Let *Stub\_\_c.String\_\_c* = '**\["YESTERDAY", "NOW", "TOMORROW"]**' and *Stub\_\_c.Area\_\_c* = '**NEXT YEAR**'.

`IN('NEXT YEAR', JPARSE({Stub__c.String__c}), {Stub__c.Area__c}, 'PREVIOUS YEAR')` will return **true**.
{% endtab %}
{% endtabs %}

## 8. NOTIN

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

{% tabs %}
{% tab title="Usage" %}
`NOTIN(value, list_of_values OR [value1, value2, ...])`&#x20;

Replace:

`value` with value you need to check in list;

`list_of_values` with the list to compare value parameter to (or pass list of values as separate parameters  `value1`, `value2`, etc).&#x20;

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

{% tab title="Example 1" %}
`NOTIN({Opportunity.Stage}, 'Lost', 'Won', 'Review', 'Needs Analysis')` returns **true** if *Opportunity.Stage* field value is not present in the given set of strings (`'Lost', 'Won', 'Review', 'Needs Analysis'`) and **false** if it is present there.
{% endtab %}

{% tab title="Example 2" %}
Let *Stub\_\_c.String\_\_c* = '**\["YESTERDAY", "NOW", "TOMORROW"]**'.

`NOTIN('NOW', JPARSE({Stub__c.String__c}))` will return **false**.
{% endtab %}

{% tab title="Example 3" %}
Let *Stub\_\_c.String\_\_c* = '**\["YESTERDAY", "NOW", "TOMORROW"]**' and *Stub\_\_c.Area\_\_c* = '**NEXT YEAR**'.

`IN('NEXT MONTH', JPARSE({Stub__c.String__c}), {Stub__c.Area__c}, 'PREVIOUS YEAR')` will return **true**.
{% endtab %}
{% endtabs %}

## 9. INSTANCEOF

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

{% tabs %}
{% tab title="Usage" %}
`INSTANCEOF(value, Decimal|Boolean|String|Date|DateTime)`&#x20;

Replace `value` argument with a value you want to validate and pass one of the allowed types (`Decimal`, `Boolean`, `String`, `Date` or `DateTime`) as second argument.
{% endtab %}

{% tab title="Example" %}
`INSTANCEOF({$Variables.Result}, Decimal)` will return **true** if variable "*Result*" is a number, and **false** if it is not.
{% endtab %}
{% endtabs %}
