# Form Features - Use Dynamic Salesforce Data with Record Datasets

## Overview

[**Record Datasets**](https://docs.sharinpix.com/forms/salesforce-integration/record-datasets) let you use Salesforce data inside SharinPix Forms.

This feature is currently available for **Select** and **Multi-Select** questions. It lets you populate options from a **Record Dataset** generated from Salesforce records.

Use it when the available options should reflect Salesforce data instead of a fixed list entered in the form builder.

{% hint style="info" %}
Refresh your Record Datasets regularly to keep options in sync with Salesforce.
{% endhint %}

This article covers:

* [Configure dynamic Select or Multi-Select options with a Record Dataset](#configure-dynamic-select-or-multi-select-options-with-a-record-dataset)
  * [Choose the label and value fields](#choose-the-label-and-value-fields)
  * [Filter available rows](#filter-available-rows)
* [Demo: Select Employees based on their Company](#demo-select-employees-based-on-their-company)

### Configure dynamic Select or Multi-Select options with a Record Dataset

Add a **Select** or **Multi-Select** question.

<figure><img src="https://2647402409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRD1Xcn9HtKcyfQ9Ghyk%2Fuploads%2FkDzyfThWBEULKUByLGso%2FDOC%20SF%20-%201920%20x%201080%20(33).png?alt=media&#x26;token=8d714004-dd62-4627-abb5-5f4f3976f645" alt=""><figcaption></figcaption></figure>

In the **Options** tab, click **Select a dataset** and choose one of the available **Record Datasets**.

{% hint style="info" %}
Create the Record Dataset first before configuring the question.

Refer to [How to Create a Record Dataset](https://docs.sharinpix.com/forms/salesforce-integration/record-datasets#how-to-create-a-record-dataset).
{% endhint %}

<figure><img src="https://2647402409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRD1Xcn9HtKcyfQ9Ghyk%2Fuploads%2FbJD0ql5qNzI2vj3ShR6e%2F2.png?alt=media&#x26;token=fdc3d269-82bc-4620-822b-74328c7bba5b" alt=""><figcaption></figcaption></figure>

The available fields depend entirely on the columns exported into the Record Dataset.

In this example, the dataset includes:

* `Id`
* `Name`
* `SiteAddress__c`
* `SiteArea__c`
* `SiteType__c`
* `Inspection__c`

If a field is not present in the dataset, you cannot use it in the question configuration or the filter formula.

<figure><img src="https://2647402409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRD1Xcn9HtKcyfQ9Ghyk%2Fuploads%2FLObLVtt2fdFGFCvwyd7Q%2F3.png?alt=media&#x26;token=6e5b8585-b817-4c0c-bdc0-bd72b4aead7e" alt=""><figcaption></figcaption></figure>

### Choose the label and value fields

After selecting the dataset, choose which column should be used as:

* the **label**, which is shown to the user
* the **value**, which is stored in the form response

In most cases, use a readable field for the label and a stable field for the value.

For example, you might display `Name` while storing `Id`.

You can keep static options or remove them, depending on whether the question should rely entirely on the selected dataset.

<figure><img src="https://2647402409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRD1Xcn9HtKcyfQ9Ghyk%2Fuploads%2FIe4xZjW4VqkZEKV3rkjI%2F4.png?alt=media&#x26;token=4a54a412-aaf1-479e-9e4a-66db1b0b602b" alt=""><figcaption></figcaption></figure>

#### Filter available rows

In the **CSV Filter (formula)** field, reference dataset columns with `row.<column_name>`.

You can use any column exported in the dataset inside the filter.

With the example dataset above, valid references include:

* `row.Id`
* `row.Name`
* `row.SiteAddress__c`
* `row.SiteArea__c`
* `row.SiteType__c`
* `row.Inspection__c`

Use this filter to show only rows that match specific values.

In this example, the filter keeps only Site records where `SiteArea__c > 500`.

<figure><img src="https://2647402409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRD1Xcn9HtKcyfQ9Ghyk%2Fuploads%2Fy56jRbnY9O6f4m3C0D6n%2F5.png?alt=media&#x26;token=765dcb18-682e-4c8c-a8b6-968376e34fe5" alt=""><figcaption></figcaption></figure>

For example:

* `row.SiteArea__c > 500` keeps only large sites
* `row.SiteType__c == "Industrial"` keeps only industrial sites
* `row.Inspection__c == inspection_id` keeps only sites linked to the current Inspection

The available options now include only records where `SiteArea__c` is greater than `500`.

<figure><img src="https://2647402409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRD1Xcn9HtKcyfQ9Ghyk%2Fuploads%2Fag7kejxfVFuf4l0hWyT9%2F6.png?alt=media&#x26;token=576a8cc3-069b-4999-adb8-4b4be4732207" alt=""><figcaption></figcaption></figure>

#### Remove duplicate values

If the dataset contains repeated values in the same column, the question can show duplicate options.

Enable `Remove duplicate values from CSV` to keep only one option for each repeated value.

<figure><img src="https://2647402409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRD1Xcn9HtKcyfQ9Ghyk%2Fuploads%2FAaBNvfuWjD1Pe87dMzw5%2FCopy%20of%20DOC%20SF%20-%201920%20x%201080.png?alt=media&#x26;token=01c15693-8c9e-44ae-9975-337209a94265" alt=""><figcaption></figcaption></figure>

### Demo: Select Employees based on their Company

{% hint style="warning" %}
**Prerequisite for this example:**

* Create a **Companies** dataset.
* Create an **Employees** dataset with a `Company__c` lookup field.
  {% endhint %}

#### Step 1: Set up the company Select question

Add a **Select** question with the API name `company`.

Select the **Companies** dataset.

Use `Name`, or another readable field, as the label.

Use `Id` as the value. This value will be used to filter the **Employees** dataset.

<figure><img src="https://2647402409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRD1Xcn9HtKcyfQ9Ghyk%2Fuploads%2FeMnHH6OxvFRaraKwPbBK%2FDOC%20SF%20-%201920%20x%201080%20(37).png?alt=media&#x26;token=106ea48e-8793-4626-afba-84ca34a8c357" alt=""><figcaption></figcaption></figure>

#### Step 2: Set up the employees Multi-Select question

Add a **Multi-Select** question.

Select the **Employees** dataset.

Use [Filter available rows](#filter-available-rows) to keep only employees linked to the selected company.

In this example, use:

`row.Company__c == company.value`

<figure><img src="https://2647402409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRD1Xcn9HtKcyfQ9Ghyk%2Fuploads%2FVK9N8AbEzV2AyM1mnZkU%2FDOC%20SF%20-%201920%20x%201080%20(38).png?alt=media&#x26;token=42854db1-ac1f-4891-9ca6-5091be8295de" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
**Tip:**\
\
If you want to get the company ID from the form launch URL, or from a Salesforce field on the record where the form is launched, configure a hidden text question with [Prefill](https://docs.sharinpix.com/forms/form-elements/form-features-default-or-prefill-values). You can then reference that hidden field in the filter instead.
{% endhint %}
