> 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/queries-and-conditions/working-with-conditions/query-conditions.md).

# Query conditions

Open conditions section (1) and select **Query** condition type (2):

![](/files/4ca53b7a79754b0585ee05d665a75657b8bd236e)

You can use Standard or Advanced config mode to create condition.

**Standard** Query config mode allows user to create condition using only process data source object fields, while selecting **Advanced** Query config mode adds Object picklist where user is to choose from the list of available objects (3):

![](/files/276a077ac4d7312af2a5f006b811f0fb28dcbcbe)

* Click "Add Condition" button
* Select fields, operators and set values
* Add more conditions

![](/files/bcf8c532d1234b3bb698c8838058882dce27cf4b)

## Operators

### For any field

* **Equals** - strict equality of value of selected field to one that is specified in "Value" field (for dates and times - matching selected range)
* **Not equal to** - opposite to previous (strict unequality; for dates and times - out of selected range)
* **Is null** - value of selected field is blank or absent (not set at all)
* **Is not null** - opposite to previous (value of selected field exists and it is not blank)

### For text and picklist fields

* **Starts with** - value of selected field starts with a substring (group of symbols) specified in "Value" field
* **Contains** - value of selected field contains a substring specified in "Value" field
* **Does not contain** - opposite to previous (value of selected field does not contain a specified substring)

### For numeric (number, currency, percent, etc.) and date (date, time, datetime) fields

For date fields, "less" means "earlier" and "greater" means "later".

* **Less than** - value of selected field is less than one specified in "Value" field
* **Greater than** - value of selected field is greater than one specified in "Value" field
* **Less or equal** - value of selected field is less than one specified in "Value" field or equal to it
* **Greater or equal** - value of selected field is greater than one specified in "Value" field or equal to it

### For multiselects

* **Includes** - value of selected field includes one specified in "Value" field (suitable to fields that does not support "contains" operator, like lists of IDs)
* **Excludes** - opposite to previous (value of selected field does not include one specified in "Value" field)

### For picklists, IDs, and lookups

* **In** - value of selected field is in the list of values provided in "Value" field
* **Not in** - opposite to previous (value of selected field is not in the list of values provided in "Value" field)

Operators "In / Not in" take lists of values in the following formats, in order of priority from highest to lowest:

* JSON array - `["Value1","Value2","Value3"]`
* String with `;` delimeter - `Value1;Value2;Value3`
* String with `,` delimeter - `Value1,Value2,Value3`

If value have an umbiguous content, system will interprete in the order shown above.

For example, the string `Value1;Value2;Value3,4;Value5` will be interpreted as `["Value1", "Value2", "Value3,4", "Value5"]`, not as `["Value1;Value2;Value3", "4,Value5"]`.

## Values

Values can be of different types:

* **Value** - some static value
* **Field** - values of the the fields of the Source object
* **Formula** - compare with Merge fields of Context objects using formulas.

## Condition logic

Provide condition logic expression if necessary (4):

![](/files/15f891812262f0d4be28dc7ef003dde5386e5b25)

Condition logic is build based on list of conditions user created.

If you don't fill Logic field this means **all conditions** must be matched.

To use conditions in Logic expression user needs to operate with conditions **Indexes** (5). So, in the example above **{1}** will represent `Opportunity.Closed = true` condition, **{2}** will represent `Opportunity.Fiscal_Quarter = 2` condition, etc.

Each condition Index must be enclosed in curved brackets.

Following operators can be used when creating logic based on list of indexed conditions:

* **OR** evaluates if at least one of multiple values or expressions is true.
* **AND** evaluates if two values or expressions are both true.
* **NOT**(*expression that you want evaluated*) - inverts logical expression in brackets (returns `false` for `true` and `true` for `false`).
* **( )** - specifies that the expressions within parentheses are evaluated first. All other expressions are evaluated using standard operator precedence.

## Examples

<details>

<summary>Examples</summary>

Following condition will be met in case one of the listed clause return `true`.

![](/files/780cdb1c79df6b84c8382389d805edaa5cb7c0e4)

Following condition will be met in case opportunity is not Closed, Fiscal Quarter value is 2 and either opportunity record has line items or Probability value is greater than 80%.

![](/files/e44a1b7651165c22ad58c8879535b26716d908cd)

Following condition will be met in case opportunity is in Closed state, Probability value is less than 80% and either Fiscal Quarter is not 2 or opportunity has no Line Items.

![](/files/1a4cdb3840786ba0d33800d01083469d47c0b58c)

</details>

## Creating complex query condition logic

**{BR}** operator is used to create WHERE part of Condition logic. Everything that goes after **{BR}** works the way clauses do after WHERE statement in Salesforce Object Query Language. Use [SOQL SELECT Syntax](https://developer.salesforce.com/docs/atlas.en-us.202.0.soql%5Fsosl.meta/soql%5Fsosl/sforce%5Fapi%5Fcalls%5Fsoql%5Fselect.htm) after **{BR}** operator.

**{BR}** operator must go after base condition logic.

<details>

<summary>Examples</summary>

Following condition will be met in case where:

`opportunity is not in Closed state` **and** `Fiscal Quarter is 2`\
**OR**\
both `Has Line Item is true` **and** `Probability is greater than 80%` **AND**\
query will only include opportunity where `CreatedBy.Email='user@email.com'` **or** `LastModifiedDate > YESTERDAY`.

![](/files/4ff835985453a09f4a219eb267c513dca56f6bc8)

Following condition will be met in case where:

`opportunity is in Closed state` **and** `Fiscal Quarter is not 2` **OR**\
both `Has Line Item is false` **and** `Probability is lower than 80%` **AND**\
query will only include opportunity where `CreatedBy.Email value is not 'user@email.com'` **or** `LastModifiedDate equals or greater than YESTERDAY`.

![](/files/7e572d803d79ce7cd2c11b8cf70b6a6dee8fb101)

</details>
