# Custom Search Types

## Custom Lookup Types

With Sonoran CAD’s custom records, communities can define custom lookup types that enable users to search records using tailored criteria.

Example: Vehicle Search — locate a registration by attributes such as make, model, color, etc.

<figure><img src="https://232668649-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4pGN81fb4R6zFhodcu%2Fuploads%2FuNAI2nIjDUCAIl5XdsZz%2Flookup_type_promo.png?alt=media&#x26;token=a784bafb-b2f3-47ca-8755-f02eb7ee723b" alt=""><figcaption></figcaption></figure>

## Configuring Lookup Types

Lookup Types can be customized under **Admin** > **Customization** > **Customization** > **Lookup Types**

### Basic Lookup Types

Basic lookup types allow you to search based on a single record field.

In this example, we will create a lookup type to look for a civilian character's SSN (Social Security Number).

<details>

<summary>1. Add Lookup Type</summary>

Select **Add Lookup Type** at the bottom of the menu.

Enter the lookup name, **SSN**.

<figure><img src="https://232668649-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4pGN81fb4R6zFhodcu%2Fuploads%2FKY2b037ugGqv4Yi0pAiQ%2Fimage.png?alt=media&#x26;token=c253365d-a61a-4a40-968f-e201bac1309a" alt=""><figcaption></figcaption></figure>

</details>

<details>

<summary>2. Select the Record Field</summary>

Select the **Record Field** button. This will open a dialog to select a specific record field. Once selected, this field will be searchable when opening a record lookup.

<div><figure><img src="https://232668649-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4pGN81fb4R6zFhodcu%2Fuploads%2FnQNVKt7cc73LJC2mM7xU%2Fimage.png?alt=media&#x26;token=af585fab-5cf5-46f5-803a-4c8f2df3e5e0" alt=""><figcaption></figcaption></figure> <figure><img src="https://232668649-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4pGN81fb4R6zFhodcu%2Fuploads%2Fr9WUyCDX96k6IT2YTZ3N%2Fimage.png?alt=media&#x26;token=a41f97c9-487a-487a-a213-1c075139165e" alt=""><figcaption></figcaption></figure></div>

</details>

<details>

<summary>3. Optional: Re-Index Record Fields</summary>

Whenever a record is created or updated, any fields tied to custom lookup types are re-indexed in the database. These indices are what power custom lookup queries.

To ensure records created before a custom lookup type existed are included, [those records must be re-indexed](#re-index-records).

</details>

### Advanced Lookup Types

Advanced lookup types allow you to search based on multiple record field criteria at once.

In this example, we will create a lookup type to look for a character based off of optional address, height, weight, skin color, etc.

<details>

<summary>1. Add Lookup Type</summary>

Select **Add Lookup Type** at the bottom of the menu.

Enter the lookup name, **Character**.

Toggle the mode to **Advanced**.

<figure><img src="https://232668649-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4pGN81fb4R6zFhodcu%2Fuploads%2F1N1rFFqIth2bvIJpjLvJ%2Fimage.png?alt=media&#x26;token=2f041204-1366-432c-b2a9-9ad8fb1425b7" alt=""><figcaption></figcaption></figure>

</details>

<details>

<summary>2. Select the Record Fields</summary>

Advanced lookup types work the same as basic lookup types, but allow for more than one criteria.

* Select the **Add Field** button.&#x20;
* Enter a **Field Label** (Address).
* Select the **Record Field**. This will open a dialog to select a specific record field.

<div><figure><img src="https://232668649-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4pGN81fb4R6zFhodcu%2Fuploads%2FhWQO3pYxkYcaZv5M6AmJ%2Fimage.png?alt=media&#x26;token=6e93108f-2694-410d-8a59-081414b764fc" alt=""><figcaption></figcaption></figure> <figure><img src="https://232668649-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4pGN81fb4R6zFhodcu%2Fuploads%2FOArJ0iR7T4OZYgrnBNjp%2Fimage.png?alt=media&#x26;token=0943120f-5d97-4f37-a974-8e91c06aecc5" alt=""><figcaption></figcaption></figure></div>

Repeat the steps above to add as many search fields as desired.

</details>

<details>

<summary>4. Additional Field Options</summary>

**Requirement**

Toggle **Requirement** from **Optional** to **Required** to force users in the lookup window to enter data into this field prior to running a lookup.

**Width**

The **Width** determines how wide the search field is in the lookup window. For custom search types with several search fields, this can be used to condense the UI.

Width values range from 1-12, with 12 being full-width.

Select the **Preview** button at the top of the section to see the layout of your custom lookup type. Fields can be reordered via drag-and-drop.

<figure><img src="https://232668649-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4pGN81fb4R6zFhodcu%2Fuploads%2FA3CK3wFTeXRH5DH1oJZy%2Fimage.png?alt=media&#x26;token=93a70260-fa9e-46cf-914b-37e7b6d3839c" alt=""><figcaption></figcaption></figure>

**Range Search**

Text fields with a mask restricting input to numbers only (`#` symbol) will display the option to enable a range input. This allows users to search based on minimum and maximum number values.

Ex: Search by minimum and/or maximum age.

**Placeholder**

Placeholder text will be displayed inside the lookup field when empty.

**Mask**

Custom text input search fields can have a mask applied to enforce a specific format of numbers, symbols, letters, etc.

</details>

<details>

<summary>3. Optional: Re-Index Record Fields</summary>

Whenever a record is created or updated, any fields tied to custom lookup types are re-indexed in the database. These indices are what power custom lookup queries.

To ensure records created before a custom lookup type existed are included, [those records must be re-indexed](#re-index-records).

</details>

## Re-Index Records

Whenever a record is created or updated, any fields tied to custom lookup types are re-indexed in the database. These indices are what power custom lookup queries.

To re-index all existing records, select **Re-Index All Records** at the top to start this process.

Depending on the number of custom records in your community, this may take some time. **Record re-indexing can only be performed once per 12-hours.**

<figure><img src="https://232668649-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4pGN81fb4R6zFhodcu%2Fuploads%2FBdO4UTc2AdYZCP51rynE%2Fimage.png?alt=media&#x26;token=5a0f99bc-abf8-4620-823e-cce9c82f8493" alt=""><figcaption></figcaption></figure>

## Lookups Across Multiple Record Types

When a custom lookup type is configured with a linked field, the system uses the **Field Mapping ID** to determine which database fields to query.

The **Field Mapping ID** defined in the lookup type is shown in the **Record Field** selector. Any [custom record type](https://docs.sonoransoftware.com/cad/tutorials/customization/creating-custom-record-and-report-types) containing a field with the same **Field Mapping ID** will be included in the search.

<div><figure><img src="https://232668649-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4pGN81fb4R6zFhodcu%2Fuploads%2FskSOrZFbTEYpzip5TI08%2Fimage.png?alt=media&#x26;token=24057a2a-f46a-4304-89dc-cf930094044b" alt=""><figcaption></figcaption></figure> <figure><img src="https://232668649-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4pGN81fb4R6zFhodcu%2Fuploads%2Ft6LjzG6uiz1diLcKFkg7%2Fimage.png?alt=media&#x26;token=d31633e5-8ff4-417c-b5fd-01a41109668a" alt=""><figcaption></figcaption></figure></div>

## Database Sync Configuration

<details>

<summary>Database Sync Configuration</summary>

If the search field is provided by your in-game database with [database sync](https://docs.sonoransoftware.com/cad/integration-plugins/database-sync-and-merge), this custom record column will be display in your database sync configuration for any character, license, or vehicle registration.

This will then allow you to search characters, licenses, or vehicle registrations from your in-game database based on this custom column value.

![Sonoran CAD - Database Sync and Custom Searches](https://232668649-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4pGN81fb4R6zFhodcu%2F-MT8wTxDTZkQkt6SPSQC%2F-MT90amKes6zgBvv6zzK%2Fimage.png?alt=media\&token=6a8609e4-eb18-4a39-85e6-673b21d7e7ea)

</details>
