Queries
You can use queries to return search results from your system. Below you'll learn how queries work and how to build them.
Please note
This guide explains how to use the query endpoint. For the reference page where you can try out queries, click here.
What are queries
Search queries are used to locate specific records within your CRM. Each search query will look for results within a specified object, and generate a list of records which match the specifications you've set. You can also use the query fields to choose which data will be returned and in what order.
How to use the query field
The query field is used to search through the system. It will specifically search through the records within the object you set in the objecttype field, and then return all the records which meet the query conditions. Each query is made up of statements. Each statement should be surrounded by parenthesis and contain the three sections detailed below.
- System field: The system field name of the field you'd like to search for a value in, such as accountname.
- Operator: The operator you'd like to use to check the system field, such as start-with. You can find a list of all the different operators below.
- ValueThe value you'd like to compare to the system field using the operator, such as 'Bob D'. If you'd like to include a string with whitespace, enclose your value in single quotation marks.
For example, you can use the statement (accountname start-with 'Bob D') in the query field to return a list of all the account records in your system where their name starts with the phrase Bob D.
Important note
You must use single quotation marks and not double quotation marks. The curl request box may display an error, simply ignore it and use the Try It! button to send your request.
Multiple statements
You can use multiple statements in a search query if you'd like to limit your results by more than one condition. Each statement must be in its own set of parenthesis, and connected using one of the following logical operators:
- AND: By using this operator, a record must meet both conditions in order to be included in the list of returned results. For example, the query (accountname start-with 'Bob D') AND (statuscode = 6) will only return accounts which have both their status set to 6, which represents the lead status, and their account name starts with 'Bob D'.
- OR: By using this operator, a record must meet at least one of the conditions in order to be included in the list of returned results. For example, the query (accountname start-with 'Bob D') OR (statuscode = 6) will return accounts which have either their status set to 6, which represents the lead status, or their account name starts with 'Bob D'.
Please note
You can include as many statements as you want. Make sure that each statement is surrounded by parenthesis and uses either the AND or OR operator between the two statements. Eeach set of statements should have its own parenthesis. For example, you can use the search query ((accountname start-with 'Bob D') AND (statuscode = 6)) OR (accountnumber >= 50). This will return accounts which have both their status set to 6, which represents the lead status, and their account name starts with 'Bob D', as well as any account records with an account number greater than or equal to 50.
Operators
Below you'll find a list of the different operators you can use within your query statements.
- = : Checks if the set field's value is exactly equal to the value set in the query.
- !=: Checks if the set field's value is not exactly equal to the value set in the query.
- <: Checks if the set field's value is less than the value set in the query. This operator can be used for number or date fields. For date fields, this means all records where the date occurred before the date set as the value will be returned.
- >: Checks if the set field's value is greater than the value set in the query. This operator can be used for number or date fields. For date fields, this means all records where the date occurred after the date set as the value will be returned.
- <=: Checks if the set field's value is less than or equal to the value set in the query. This operator can be used for number or date fields. For date fields, this means all records where the date occurred before or on the date set as the value will be returned.
- >=: Checks if the set field's value is greater than or equal to the value set in the query. This operator can be used for number or date fields. For date fields, this means all records where the date occurred after or on the date set as the value will be returned.
- start-with: Checks if the set field's value starts with the phrase used in the value section of the query. By putting % before the set value, this operator will instead check if the set value occurs anywhere within the set field.
- not-start-with: Checks if the set field's value does not start with the phrase used in the value section of the query. By putting % before the set value, this operator will instead check if the set value does not occur anywhere within the set field.
- is-null: Checks if the set field's value is empty. When using this operator, do not set a value.
- is-not-null: Checks if the set field's value is not empty. When using this operator, do not set a value.
Updated 6 months ago