# SharinPix Form Formula: Fields and Attributes

### Overview <a href="#overview" id="overview"></a>

{% hint style="info" %}
The **SharinPix Form Formula Field** allows you to dynamically reference and manipulate data. Using formulas, you can combine static values with live data coming from form inputs and other sources to create flexible, data-driven form templates.

This article covers the following:

* [Accessing Form Fields](#overview)
* [Accessing Attributes of Form Fields](#accessing-attributes-of-form-fields)
  {% endhint %}

{% hint style="success" %}
**Tips:**&#x20;

[Follow this documentation](/forms/form-elements/sharinpix-form-formula-functions-and-operators.md) to learn more about the Functions and Operators available in a SharinPix Form Formula Field
{% endhint %}

### Getting Started <a href="#getting-started" id="getting-started"></a>

Formulas can reference data from the following sources:

1. **Current Form Fields:** Values entered by the end-user (e.g., <mark style="color:red;">`elementAPIName`</mark>).
2. **URL Parameters:** Data passed when launching the form via the <mark style="color:red;">`form.params.`</mark> prefix (e.g., <mark style="color:red;">`form.params.approval_threshold`</mark>).

### Accessing Form Fields <a href="#configure-visibility-conditions-1" id="configure-visibility-conditions-1"></a>

Any question with an API name can be used in a formula field. An API name can be added to a question using the *API Name field* on the form builder, as shown below.

<figure><img src="/files/EtSfrT6wqfOpOTTGcXad" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/hptQvu5TtXb3mVWkPufY" alt=""><figcaption></figcaption></figure>

The SerialNumber field can then be used in formula fields as shown above

{% hint style="danger" %}
A section or page cannot contain fields with the same API name.
{% endhint %}

#### Accessing nested fields <a href="#accessing-nested-fields" id="accessing-nested-fields"></a>

To access a nested field, i.e a field found inside a section, make sure to add an API name to the Section element as well. In the picture below the API name "Bedroom" is added to a Section element.

<figure><img src="/files/a3jeMmRyrf54kV5FMi58" alt=""><figcaption></figcaption></figure>

The "Bedroom" Section element contains a Radio question with the "ACWorking" API name as shown below.

<figure><img src="/files/IWjqIv71NfsKS0nc0YrF" alt=""><figcaption></figcaption></figure>

To reference the "ACWorking" Radio question in a formula field found **outside** the "Bedroom" Section, it should be *prefixed* with the Section's API name as shown in the example below.

<figure><img src="/files/VjX33hWoNE3ckYByCtsu" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
**Tips:**&#x20;

A field can be referenced without any prefix if it is being used in the same level (i.e, the section where it is found)
{% endhint %}

#### Accessing parent fields

The <mark style="color:red;">`parent`</mark> attribute is available for any question found in a section.

<figure><img src="/files/85i1KhNEPLTvGTNp2tb0" alt=""><figcaption></figcaption></figure>

By using the <mark style="color:red;">`parent`</mark> attribute, we can access the attributes of the section as shown below.&#x20;

<figure><img src="/files/ctsGvwWV3rgLc0Ewb4dv" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
**Tips:**

You can use <mark style="color:red;">`.parent`</mark> to move up the elements tree and reference questions in other sections. For example:

<mark style="color:red;">`parent.parent.SiblingSection.ACWorking`</mark>
{% endhint %}

if you need to reference a **root-level (main page)** question inside a formula field for a question **nested** in a section, you can reference it by using the [**form**](#global-form-attributes) global field.

In the example below, the form includes a radio question with the API name <mark style="color:red;">`VisitType`</mark> on the main page, and a capture question inside the **Bedroom** section.

<figure><img src="/files/7xctdvjq481ydHpvXS3G" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/tdnAC6gBiVc9JTRWTV22" alt=""><figcaption></figcaption></figure>

To reference <mark style="color:red;">`VisitType`</mark> from a formula on a question in the **Bedroom** section, use <mark style="color:red;">`form.VisitType`</mark>, as shown below.

<figure><img src="/files/vpwC39afCDmKw8Xte48j" alt=""><figcaption></figcaption></figure>

### Accessing Attributes of Form Fields <a href="#accessing-attributes-of-form-fields" id="accessing-attributes-of-form-fields"></a>

A field can contain several attributes based on its type and they can be accessed by adding a "." following a field API name.

#### Generic Questions attributes <a href="#generic-questions-attributes" id="generic-questions-attributes"></a>

These attributes are available on almost all questions.

<figure><img src="/files/GSLUFxKk7pazL0I6kawz" alt=""><figcaption></figcaption></figure>

| Attribute    | Purpose                                                                                                                                                                               |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| value        | Returns the current value of the field                                                                                                                                                |
| displayValue | Returns the current value of the field as displayed on the UI                                                                                                                         |
| label        | Returns the label of the question                                                                                                                                                     |
| mediaCount   | Returns the number of media associated with the question                                                                                                                              |
| note         | Returns the current note added to the question if any                                                                                                                                 |
| reference    | Return the previous value of the question in the context of a [follow-up form](/forms/advanced-form-configuration/form-features-initial-follow-up-form-responses-comparative-form.md) |
| visible      | Returns whether the question is currently visible or not (This is available to use only if the question has a visibility formula configured)                                          |

**displayValue attribute**

This attribute returns the current value of the field as shown on the UI.

For example, if a question has a label configured for a particular value, then that label will be returned in the formula as shown below.

<figure><img src="/files/4stIVs9mCShDeGJGYDcq" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/LX2qbOtYLOazrO8f3KUp" alt=""><figcaption></figcaption></figure>

For date questions it returns the date value as a formatted string, using the date format configured on the question.

<figure><img src="/files/d60uvNLioEqvpjXN9Pbv" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/pYxzeyIvFJFRMDJtiF3O" alt=""><figcaption></figcaption></figure>

#### Section Attributes <a href="#section-attributes" id="section-attributes"></a>

These attributes are only available to sections.

<figure><img src="/files/j6lJY9UMp0rQGbuLl5R8" alt=""><figcaption></figcaption></figure>

| Attribute              | Purpose                                                                     |
| ---------------------- | --------------------------------------------------------------------------- |
| \_questionsCount       | Returns the number of visible questions that are inside the section         |
| \_questionsFilledCount | Returns the number of visible questions that have filled inside the section |
| index                  | Returns the index of the section if it a repeated section                   |

The API names of the questions inside the Section are also attributes of the Section.

If a Section is a Repeated Section, it will also have the <mark style="color:red;">`index`</mark> attribute, which returns its position in the Repeated element as shown below.

<figure><img src="/files/xa4lNMAOPNY5XIgMCFdv" alt=""><figcaption></figcaption></figure>

### Repeated Sections attributes

These attributes are only available to the Repeated Sections element.

<figure><img src="/files/FlF4djJX77JZ0m32kHN3" alt=""><figcaption></figcaption></figure>

| Attribute | Purpose                                          |
| --------- | ------------------------------------------------ |
| size      | Returns the number of sections added by the user |

The nested fields of the repeated sections can also be referenced. Follow [this documentation](/forms/form-sections-and-repeated-sections/sharinpix-form-formula-referencing-repeated-section-fields.md) to learn more.

#### Global form attributes <a href="#global-form-attributes" id="global-form-attributes"></a>

There are several global attributes that can be accessed by using the <mark style="color:red;">`form`</mark> keyword

<figure><img src="/files/d2Nd47l2bXv6pWR4CPcV" alt=""><figcaption></figcaption></figure>

| Attribute | Purpose                                                                                                                                                                                                                         |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| compare   | Returns <mark style="color:red;">`true`</mark> when the form being filled is a follow-up form.                                                                                                                                  |
| params    | Allows accessing the url params found in the url that was used to load the form. Follow [this documentation](/forms/advanced-form-configuration/sharinpix-forms-context-parameters.md) to learn more about this attribute.      |
| response  | Returns details of the SharinPix Form Response record. This can be used to show additional details on the [SharinPix Form PDF](/forms/form-pdf-configuration/sharinpix-forms-pdf-configuration.md).                             |
| template  | Returns details of the SharinPix Form Template record.                                                                                                                                                                          |
| view      | Returns <mark style="color:$danger;">`"print"`</mark> in the context of pdf. This is useful for hiding or show specific fields on the [SharinPix Form PDF](/forms/form-pdf-configuration/sharinpix-forms-pdf-configuration.md). |

**response attribute**

This attribute of the <mark style="color:red;">`form`</mark> global field contains nested attributes about a SharinPix Form Response record created by the form.

<figure><img src="/files/mPmBcnTA9KS3V0O6UeHw" alt=""><figcaption></figcaption></figure>

| Attribute | Purpose                                                |
| --------- | ------------------------------------------------------ |
| sfid      | The Salesforce Record ID linked to the form response   |
| sfname    | The Salesforce Record Name linked to the form response |

**template attribute**

This attribute of the <mark style="color:red;">`form`</mark> global field contains nested attributes about the SharinPix Form Template record.

<figure><img src="/files/ClRCGfNO9UQU6Px6DsIZ" alt=""><figcaption></figcaption></figure>

| Attribute | Purpose                |
| --------- | ---------------------- |
| sfid      | The Form Template ID   |
| sfname    | The Form Template Name |

**Root-level fields**

The questions found on the main page can also be referenced directly by using the <mark style="color:red;">`form`</mark> field as shown below.

<figure><img src="/files/f8Rh2hyQ6LrKIxWrzFKo" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
**Tips:**

This can be used to reference a root-level question from a nested formula field.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sharinpix.com/forms/form-elements/sharinpix-form-formula-fields-and-attributes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
