---
title: Useful Examples
slug: useful-examples
createdAt: 2023-03-26T13:52:10.000Z
---

## Search by e-mail address

Use the <font color="#eb144c">`Email Addresses`</font> link to search *all* e-mail addresses, not only the primary ones.

::Image[]{src="https://api.archbee.com/api/optimize/fRibh2_2NwaS_4MGgrZuA/TXMSs3rrlXko9K76N5oED_emailaddrpick.png" size="38" width="1081" height="723" position="center" showCaption="false"}

::Image[]{src="https://api.archbee.com/api/optimize/fRibh2_2NwaS_4MGgrZuA/xJdEXBpIROuNyw81HlwTL_emailquery.png" size="50" width="1158" height="192" position="center" showCaption="false"}

***

## Searching e-mails by e-mail addresses

It is necessary to explicitly search the e-mail address on the **`From`**, **`To`**, **`Cc`** or **`Bcc`** links.

![](https://api.archbee.com/api/optimize/fRibh2_2NwaS_4MGgrZuA/B7N2JV-r7GdBmKmWXYf0l_emailfields.png)

Here is an example of searching for <font color="#eb144c">`E-mails`</font> having <font color="#3b9f0f">`"sarah"`</font> in either the **`From`** or **`To`** fields:

![](https://api.archbee.com/api/optimize/fRibh2_2NwaS_4MGgrZuA/hKJkZFHP2h5S1YPCnZT3K_emailsearch.png)

***

## Searching by tags

Search by the <font color="#fcb900">`name`</font> field on the <font color="#eb144c">`Tags`</font> link:

::Image[]{src="https://api.archbee.com/api/optimize/fRibh2_2NwaS_4MGgrZuA/H80JyPYg7m2gYnbYcsbIQ_tagsquery.png" size="48" width="574" height="142" position="center" showCaption="false"}

***

## Searching for favorites

Search for records that have a non-empty <font color="#fcb900">`favorite`</font> link:

::Image[]{src="https://api.archbee.com/api/optimize/fRibh2_2NwaS_4MGgrZuA/mi8O0t8fOr7Xp7JlT4bwc_favorite.png" size="48" width="471" height="119" position="center" showCaption="false"}

***

## Searching for records that you follow

Search for records that have a non-empty <font color="#fcb900">`following`</font> link:

::Image[]{src="https://api.archbee.com/api/optimize/fRibh2_2NwaS_4MGgrZuA/Dz0kV0DMT3qUYfM66TdX8_following.png" size="46" width="483" height="115" position="center" showCaption="false"}

***

## Searching multi-select fields

Use the <font color="#9900ef">`contains`</font> operator:

![](https://api.archbee.com/api/optimize/fRibh2_2NwaS_4MGgrZuA/239hrqoe7FYsIF7MbUT4G_multiselect.png)

***

## Searching for records related to a particular record

To search for records related to a particular record, it is first necessary to determine the ID of this particular record. For instance, if you wanted to search for <font color="#eb144c">`Calls`</font> related to <font color="#eb144c">`Account`</font> *Abc inc*, you would first need to find the ID of *Abc inc*. You can learn how to do this [in this FAQ.](docId\:W-qrkDeRLeW3WRPt_ZMUc)

Once you've got the ID, it's simply a matter of querying the ID field on the appropriate relationship. Assuming the ID of *Abc inc* was <font color="#3b9f0f">`b582e48a-b5ea-11ed-9a54-0242ac1b0002`</font>, this is how we would search for <font color="#eb144c">`Calls`</font> that are related to this <font color="#eb144c">`Account`</font>:

![](https://api.archbee.com/api/optimize/fRibh2_2NwaS_4MGgrZuA/MQ_MGfyl1qWpm6784MfN9_searchbyid.png)

***

## Searching for my records

There are two ways you can include a "my records" condition to your query, depending on what you need to achieve.

If you simply need to apply a query <font color="#9900ef">`and`</font> also filter the resulting records to only contain those assigned to you, you can simply use the existing <font color="#2166ae">`My records`</font> filter, which will automatically be combined with your query using <font color="#9900ef">`and`</font>:

::::VerticalSplit{layout="middle"}
:::VerticalSplitItem
::Image[]{src="https://api.archbee.com/api/optimize/fRibh2_2NwaS_4MGgrZuA/iPm5E3FYWyrA-3x2-H0UF_myrecords1.png" size="48" width="290" height="294" position="center" showCaption="false"}
:::

:::VerticalSplitItem
![](https://api.archbee.com/api/optimize/fRibh2_2NwaS_4MGgrZuA/TK1E-l0DCiAjmu4rrcU_4_myrecords2.png)
:::
::::



If you need to build more complicated queries, such as involving <font color="#9900ef">`or`</font>, you will first need to find out the ID of your user. To do that, navigate to your Profile, and copy it out of the [address bar](https://en.wikipedia.org/wiki/Address_bar). It will be located right after `records=`, as seen in the picture below.

::::VerticalSplit{layout="left"}
:::VerticalSplitItem
![](https://api.archbee.com/api/optimize/fRibh2_2NwaS_4MGgrZuA/tV58WD-pMKCrlT3IDLEK0_myrecordsid1.png)
:::

:::VerticalSplitItem
![](https://api.archbee.com/api/optimize/fRibh2_2NwaS_4MGgrZuA/B7icnaAFfUMDclFkrEK2-_myrecordsid2.png)
:::
::::

Once you have that, you can search by the <font color="#eb144c">`Assigned User Name`</font> link, and combine it with whatever you need:

![](https://api.archbee.com/api/optimize/fRibh2_2NwaS_4MGgrZuA/YbuGyZm-Zfyx4TVAucWLg_myrecordsid3.png)

***

## Searching for other users' records

In this case, the process is very similar to [searching for your own records](./#searching-for-my-records). You again have the option of combining your query with built-in filters using <font color="#9900ef">`and`</font>:

![](https://api.archbee.com/api/optimize/fRibh2_2NwaS_4MGgrZuA/tL2DLrOvpKM6DxH337EVy_otheruserrecords.png)

Alternatively, you can determine the IDs of the users you need to search by. As with your own ID, this can be copied from the [address bar](https://en.wikipedia.org/wiki/Address_bar) in the <font color="#eb144c">`Employees`</font> module, after selecting the user you're interested in:

::::VerticalSplit{layout="left"}
:::VerticalSplitItem
![](https://api.archbee.com/api/optimize/fRibh2_2NwaS_4MGgrZuA/YlifUM056YbkUCsGytAsE_otheruserrecordsid1.png)
:::

:::VerticalSplitItem
![](https://api.archbee.com/api/optimize/fRibh2_2NwaS_4MGgrZuA/cWrtUlzVmJrixaC7TF3cb_otheruserrecordsid2.png)
:::
::::

![](https://api.archbee.com/api/optimize/fRibh2_2NwaS_4MGgrZuA/XJROkiJSWU0v3epCmwLGA_otheruserrecordsid3.png)

This can then be used analogously to [searching for your own records](./#searching-for-my-records).

![](https://api.archbee.com/api/optimize/fRibh2_2NwaS_4MGgrZuA/YbuGyZm-Zfyx4TVAucWLg_myrecordsid3.png)

***

## Searching for minimal and maximal records

Using a trick, it is possible to retrieve records that are the "largest" or "smallest" by some numerical field. For instance, you can use this to search for the most valuable <font color="#eb144c">`Opportunities`</font> of each <font color="#eb144c">`Account`</font>.

The trick relies on the fact that the **largest/smallest record is always larger-/smaller-than-or-equal-to all other records**.&#x20;

Here's how you would list the most valuable Opportunities of each Account:

![](https://api.archbee.com/api/optimize/fRibh2_2NwaS_4MGgrZuA/NoWNtxmxECYH9RTuNzZ-E_maxopportunity.png)

To find the least valuable Opportunity, the query is analogous, except with <font color="#9900ef">`<=`</font>.

***

## Searching for single records

A similar trick to [the one above](./#searching-for-minimal-and-maximal-records) can be used to find records where only a single related record exists.&#x20;

This trick relies on the fact that if there is only a single record, <font color="#9900ef">`<all!>`</font> **record IDs are equal to each other**.

Here are all <font color="#eb144c">`Accounts`</font> which only have a single <font color="#eb144c">`Opportunity`</font>:

![](https://api.archbee.com/api/optimize/fRibh2_2NwaS_4MGgrZuA/bW6NHWjk-EYQ4rjbiqgn6_singleopportunity.png)

Careful, the <font color="#9900ef">`<all!>`</font> [must be on the right-hand side!](docId\:kzBTLLYb4xfJ8DF290vXI)
