# Form Features - Default or Prefill Values

## Overview

{% hint style="info" %}
SharinPix Form Elements can be configured to automatically retrieve and display values from related Salesforce records. This prefill functionality allows dynamic population of form fields using data linked to the record from which the form is launched. The configuration is done directly within the [SharinPix Form Builder](https://docs.sharinpix.com/forms/form-elements/sharinpix-form-template-editor) and supports traversing up to five levels of related (lookup) records.

This document covers:

* [How to Configure Prefill in a Form Element](#how-to-configure-prefill-in-a-form-element)
* [Prefill Syntax and Examples](#prefill-syntax-and-examples)
* [Demo: Pre-Filling Values in a Fire Safety Inspection Form](#demo-pre-filling-values-in-a-fire-safety-inspection-form)
  {% endhint %}

{% hint style="warning" %}
**Prerequisite**

Before using this feature, ensure:

* Ensure that you are using the most recent SharinPix Package Version. Follow this document to [upgrade the SharinPix package](https://app.gitbook.com/s/i8tH1o5AHthxksYgF6ij/how-to-update-sharinpix-package-from-the-appexchange)
* Users have the [SharinPix Forms Admin permission set](https://app.gitbook.com/s/5EvYRrLbUyvRh8o1jmMG/access-and-security/sharinpix-permission-sets) assigned.
  {% endhint %}

## Getting Started

### How to Configure Prefill in a Form Element

To configure prefilling for a question in a SharinPix Form:

1. Open the **SharinPix Form Builder** from the relevant Form Template.
2. Select a **Question** element in the form.
3. Navigate to the **Advanced** tab of the question configuration.
4. Enter the appropriate **Salesforce Field API Name** into the *Field API name* field.

![](https://2647402409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRD1Xcn9HtKcyfQ9Ghyk%2Fuploads%2Fgit-blob-b3e3636df47973873ddccd5e2f5f40a0d551bf00%2FPrefill%20doc.png?alt=media)

### Prefill Syntax and Examples

The prefill logic uses dot notation to access related Salesforce fields. The general format is:

* <mark style="color:$danger;">**`FieldApiName`**</mark>
* <mark style="color:$danger;">**`LookupApiName.FieldApiName`**</mark>
* <mark style="color:$danger;">**`LookupApiName.LookupApiName.FieldApiName`**</mark>

{% hint style="warning" %}
**Note**: SharinPix supports up to **5 levels of nested lookup relationships**.
{% endhint %}

**Syntax Components**

* <mark style="color:$danger;">**`LookupApiName`**</mark>: The API name of a lookup field on the current object (e.g., <mark style="color:$danger;">`AccountId`</mark> on the `Contact` object).
* <mark style="color:$danger;">**`FieldApiName`**</mark>: The API name of the target field from which to pull the value (e.g., <mark style="color:$danger;">`Description`</mark> on the <mark style="color:$danger;">`Account`</mark> object).

#### Example

If the form is launched from a **Contact** record and you want to prefill a field with the related **Account’s description,** use the following configuration:

<mark style="color:$danger;">`AccountId.Description`</mark>

This will fetch the description value of the account, which is related to the contact through the AccountId field.

<figure><img src="https://2647402409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRD1Xcn9HtKcyfQ9Ghyk%2Fuploads%2FVtXZrXbqhnboysIoZSpf%2Fscreenshot-sharinpix-fsl-demo-dev-ed.lightning.force.com-2022.04.29-16_48_15.png?alt=media&#x26;token=b34c19f8-f263-4730-985d-e0b539fdc771" alt=""><figcaption></figcaption></figure>

#### Advanced Example (Up to 5 Levels)

Example: <mark style="color:$danger;">`AssetId.ContactId.ReportsToId.AccountId.CreatedById.Name`</mark>

This fetches the name of the user who created the Account that is related through a multi-level chain from the current Asset record.

{% hint style="warning" %}
**Note:** This is subject to Salesforce’s current maximum of 5 lookup relationship levels per query.
{% endhint %}

## Demo: Pre-Filling Values in a Fire Safety Inspection Form

In this example, you have a **Form Template** designed for fire safety inspections. The form is launched from a custom **Inspection** object. Your goal is to dynamically pre-fill:

* The **inspection date** using a field on the **Inspection** record itself.
* The **address** using a field on the related **Account** record (the parent of the Inspection).

### Step 1 : Build a SharinPix Form

If you do not already have a Form Template available, go on [***SharinPix Form Template***](https://docs.sharinpix.com/forms/form-elements/sharinpix-form-template-editor) and create a new Form Template record. Use the Form Builder to create a SharinPix Form.

Once you have configured your form, you can select the element you want to have a value pre-filled from its parent record or related parent records.

<figure><img src="https://2647402409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRD1Xcn9HtKcyfQ9Ghyk%2Fuploads%2Fk1dP8wM3AwcXcfVCBVKJ%2Fscreenshot-sharinpix-fsl-demo-dev-ed.lightning.force.com-2022.04.29-16_48_15.png?alt=media&#x26;token=3690eceb-4169-47d3-912c-54f9fe598704" alt=""><figcaption></figcaption></figure>

### Step 2: Prefill the Inspection Date

Begin by selecting the Date element, which opens the configuration panel to configure pre-fill for it.

<figure><img src="https://2647402409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRD1Xcn9HtKcyfQ9Ghyk%2Fuploads%2FU938nssOUkUVOg5BfrI1%2Fscreenshot-sharinpix-fsl-demo-dev-ed.lightning.force.com-2022.04.29-16_48_15.png?alt=media&#x26;token=aa0ab442-530c-4330-8b14-90224b991dc2" alt=""><figcaption></figcaption></figure>

To pull the inspection date directly from the <mark style="color:$danger;">`Inspection`</mark> record:

* Field API Name: <mark style="color:$danger;">`Inspection_Date__c`</mark>

This retrieves the value from the <mark style="color:$danger;">`Inspection_Date__c`</mark> field on the record used to launch the form.

<figure><img src="https://2647402409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRD1Xcn9HtKcyfQ9Ghyk%2Fuploads%2F9zNmr2XClwLHpOLpWGm4%2Fscreenshot-sharinpix-fsl-demo-dev-ed.lightning.force.com-2022.04.29-16_48_15.png?alt=media&#x26;token=6f756f12-41a4-4262-8664-6676d6e4a851" alt=""><figcaption></figcaption></figure>

### Step 3: Prefill the Address from the Account

To pre-fill the **address** from the related Account record, we use:

<mark style="color:$danger;">`Account__c.Address__c`</mark>

Configuring the pre-fill value to **Account\_\_c.Address\_\_c** will do the following steps:

1. **Account\_\_c** is the Lookup Field API name on Inspection object. This will look for the parent Account record.
2. **Address\_\_c** is a field in the Account parent record. It will then fetch the Address value of this Account.

<figure><img src="https://2647402409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRD1Xcn9HtKcyfQ9Ghyk%2Fuploads%2F242vUPVBvi3ZTDwBaFSV%2Fscreenshot-sharinpix-fsl-demo-dev-ed.lightning.force.com-2022.04.29-16_48_15.png?alt=media&#x26;token=a1aa906b-d112-4965-904a-4c5b438dd5e1" alt=""><figcaption></figcaption></figure>

### Step 4: Test the form

Once the prefill values are set:

* Launch the form from a Salesforce record (e.g., an <mark style="color:$danger;">`Inspection`</mark>).
* The prefill logic will automatically populate the specified fields as shown in the diagram below.
* If a referenced field is empty (null), the form field will remain empty.

<figure><img src="https://2647402409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRD1Xcn9HtKcyfQ9Ghyk%2Fuploads%2FrmNmYZ9aw1EXWez40wmA%2Fimga-form-3.png?alt=media&#x26;token=6c3e92bb-b062-4f28-beb8-89f97ce9e481" alt=""><figcaption></figcaption></figure>
