# Automatic Form URL Generation using Flow (Admin-Oriented)

## Overview

The <mark style="color:$danger;">`GenerateFormUrlAutomation`</mark> class is an **Invocable Apex** utility that allows Salesforce Admins to automatically generate secure **SharinPix Form URLs** directly from **Flows**.

The generated URL opens a SharinPix Form on the SharinPix Mobile App or on a Web Browser for users to fill out.

This article covers the following:

1. [GenerateFormUrlAutomation's Input Parameters](https://docs.sharinpix.com/documentation/sharinpix-form/automatic-form-url-generation-using-flow-admin-oriented)
2. Flow Configuration Guide
   * [Step 1: Prepare Custom Field To Store URL](#step-1-prepare-custom-field-to-store-url)
   * [Step 2: Configure a Record-Triggered Flow](#step-2-configure-a-record-triggered-flow)
   * [Step 3: Add the Action to Generate the Form Url](#step-3-add-the-action-to-generate-the-form-url)
   * [Step 4: Add Update Element](#step-4-add-update-element)
   * [Step 5: Save and Activate the Flow](#step-5-save-and-activate-the-flow)
   * [Step 6: Find the SharinPix Form URL](#step-6-find-the-sharinpix-form-url)
3. [Demo](#demo)

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

Before configuring this automation, ensure the following:

* You have the latest **SharinPix Package** installed. This feature requires version **1.376** or higher. You can follow [this guide](https://github.com/SharinPix/documentation/blob/main/m/FAQ/l/1236928-how-to-update-sharinpix-package-from-the-appexchange/README.md) to upgrade your SharinPix Managed Package to the newest version.
* Users must have the **SharinPix Forms** **Admin** or **SharinPix Forms User** permission set assigned. For more information on these two permission sets, check [SharinPix Permission Sets](https://docs.sharinpix.com/documentation/access-and-security/sharinpix-permission-sets).
* A form template has been created using the [SharinPix Form Template Editor](https://docs.sharinpix.com/documentation/sharinpix-form/sharinpix-form-template-editor).
  {% endhint %}

## Input Parameters

Below are the inputs required when using the <mark style="color:$danger;">`GenerateFormUrlAutomation`</mark> invocable method in a Salesforce Flow. These parameters must be provided to successfully generate a SharinPix Form URL.

| Parameter        | Description                                                                                                                                                                                                                                                                                                                                                   |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| recordId         | The Salesforce Record ID (e.g. Work Order ID) to which the form url will be associated. *(Required)*                                                                                                                                                                                                                                                          |
| formTemplateId   | The ID, Name or Url of the SharinPix Form Template for which you want to generate the SharinPix Form Url. *(Required)*                                                                                                                                                                                                                                        |
| nameFieldApiName | API name of a field on the record (e.g. `WorkOrderNumber`) to be used as the job name in the SharinPix Form.                                                                                                                                                                                                                                                  |
| expiry           | Number of days after which the url will expire.                                                                                                                                                                                                                                                                                                               |
| anonymousUser    | Specifies whether the SharinPix Form should be generated for anonymous access or for an authenticated Salesforce user.                                                                                                                                                                                                                                        |
| formOnline       | Specifies whether to generate a url that opens a SharinPix Form in Online Mode (On the Web Browser).                                                                                                                                                                                                                                                          |
| customParameters | <p>Additional user-defined parameters appended to the SharinPix Form launcher URL.<br>Can add <a href="../../mobile-app/sharinpix-mobile-app-deeplink-syntax#ret_url">ret\_url</a>, prefill values parameters and so on.<br>(e.g. <mark style="color:$danger;"><code>nameFieldApiName=Name\&pvInspectionName=Room\&ret\_url=salesforce1://</code></mark>)</p> |

## Flow Configuration Guide

The following flow setup uses a **Record-Triggered Flow** to automatically generate a SharinPix Form Url when a **Work Order** is created or updated.

### Step 1: Prepare Custom Field To Store URL

A field is needed on the Work Order object to store the generated URL. To do so, create a **Text Area (Long)** field to store the entire URL.

1. Go to **Setup** > **Object Manager** > **Work Order**.
2. Click on **Fields & Relationships** > **New**.
3. Select **Text Area (Long)** as the field type.
4. Name the field (e.g., <mark style="color:$danger;">`Form Url`</mark>) and set the length to the default value (<mark style="color:$danger;">`32,768`</mark> characters).
5. **Save** the field.

This field will store the full Form URL returned by the flow.

![](https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2Fgit-blob-1093de60b7e3747204571110907a6b62a317c01a%2FDOC%20SF%20-%201920%20x%201080.png?alt=media)

### Step 2: Configure a Record-Triggered Flow

1. Go to **Setup** > **Flows** > Click **New Flow**
2. Choose **Start From Scratch** and click **Next**
3. Choose **Record-Triggered Flow** and click **Create**
4. Set the following values:

| Setting               | Value                          |
| --------------------- | ------------------------------ |
| Object                | Work Order                     |
| Trigger               | A record is created or updated |
| Set Entry Conditions  | None                           |
| Optimize the Flow for | Actions and Related Records    |

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2Fgit-blob-e0f73a8315d70bef09b9167d42dc1163ac476b1b%2Fformimg13.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2Fgit-blob-ffdb516f08fed03422e5e0bf675d5c7a693ff049%2Fformimg14%20(1).png?alt=media" alt=""><figcaption></figcaption></figure>

### Step 3: Add the Action to Generate the Form Url

{% hint style="danger" %}
**Warning:**

Starting with the Salesforce **Winter’26 release** , Apex Actions can no longer be executed directly in the **Run Immediately** path of a record-triggered flow. Instead, they must be placed in an **asynchronous path** , as the synchronous execution option is no longer supported.

For more details, please refer to the documentation here:\
[*Unable to save a flow with an Apex Action after the Salesforce Winter ’26 release – What should I do?*](https://app.gitbook.com/s/i8tH1o5AHthxksYgF6ij/i-am-unable-to-save-a-flow-with-an-apex-action-after-the-salesforce-winter-26-release-what-should-i)
{% endhint %}

1. Add an **Action** element
2. Search for <mark style="color:$danger;">`Sharinpix__GenerateFormUrlAutomation`</mark>
3. On the **Action** modal for <mark style="color:$danger;">`Sharinpix__GenerateFormUrlAutomation`</mark>, populate the fields as indicated below:

| Field               | Example Value                        |
| ------------------- | ------------------------------------ |
| Form Template ID    | Fire Safety Inspection               |
| Parent Record ID    | Triggering WorkOrder > Work Order ID |
| Expiry in Days      | 15                                   |
| Name Field API Name | WorkOrderNumber                      |
| Anonymous User      | False                                |
| Custom Parameters   | pvdate=09/05/2025                    |
| Form Online         | False                                |

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2Fgit-blob-bc2e0b9e215f59d903032d2100d1a8d0bf0d952e%2Fformimg15.png?alt=media" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
**Warning:**

* If the expiry value is not specified, the token will default to 30 days. If the token should not expire, the expiry value should be set to zero (<mark style="color:$danger;">`0`</mark>). This field only accepts whole numbers; decimal values are not supported and will result in an error.
* Ensure the specified template exists in your Salesforce org and that you have entered the correct name or ID.
  {% endhint %}

### Step 4: Add Update Element

This step is used to store the url generated by the Apex action into the custom field `FormUrl__c` you created on the Work Order.

1. Add an **Update** element
2. Select **Use the Work Order record that triggered the flow**
3. Do not add any filter conditions.
4. In the **Set Field Values for the Work Order Record** section, populate it as indicated below:

| Field        | Value                                                         |
| ------------ | ------------------------------------------------------------- |
| FormUrl\_\_c | Outputs from sharinpix\_\_GenerateFormTokenAutomation.formUrl |

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2Fgit-blob-78eb4e28963bc4bf29cffc1d7e0ad63159c2e43f%2Fformimg16.png?alt=media" alt=""><figcaption></figcaption></figure>

### Step 5: Save and Activate the Flow

**Save** the Flow and click **Activate**.

![](https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2Fgit-blob-78fb83bc8772f47a3d7f14f6e5fbfd99ca688cc0%2FDOC%20SF%20-%201920%20x%201080%20\(1920%20x%20600%20px\).png?alt=media)

### Step 6: Find the SharinPix Form URL

To test the flow, create or update a **Work Order** record.

After the flow runs, the generated **SharinPix Form URL** will be stored in the <mark style="color:$danger;">`FormUrl__c`</mark> field of the Work Order. You can view it directly from the record detail page to confirm that the token was generated successfully.

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2Fgit-blob-7d7a9ed1291bc6103d3642e26554d6bcbff8b3be%2Fformimg17.png?alt=media" alt=""><figcaption></figcaption></figure>

## Demo

The diagram below illustrates the interaction flow when a user clicks the form URL from a Work Order record, launching the SharinPix Form directly in the SharinPix Mobile App.

![](https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2Fgit-blob-7d9ef4c6c9789e0e95208638f0db1db344bfa29a%2FForm%20Url%20Doc.png?alt=media)
