Automatic Form Token Generation using Flow (Admin-Oriented)
Overview
The GenerateFormTokenAutomation
class is an Invocable Apex that allows Salesforce Admins to automatically generate secure SharinPix Form Tokens directly from Flows.
Once the token is generated, it can be used to dynamically build a URL that opens the SharinPix Form for users to fill out. This is especially useful in Field Service scenarios, where the link can launch the SharinPix mobile app directly.
This article covers the following:
Prerequisites
Before configuring this automation, ensure the following:
- You have the latest SharinPix Package installed. This feature requires version 1.346 or higher. You can follow this guide to upgrade your SharinPix Managed Package to the newest version.
- A form template has been created using the SharinPix Form Template Editor.
Input Parameters
Below are the inputs required when using the GenerateFormTokenAutomation
invocable method in a Salesforce Flow. These parameters must be provided to successfully generate a SharinPix Form token.
Parameter | Description |
---|---|
recordId | The Salesforce Record ID (e.g. Work Order ID) to which the form token will be associated. (Required) |
formTemplateId | The ID or Name of the SharinPix Form Template for which you want to generate the token. (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 token will expire. |
Flow Configuration Guide
The following flow setup uses a Record-Triggered Flow to automatically generate a SharinPix Form Token when a Work Order is created or updated.
Step 1: Prepare Custom Field To Store Token
A field is needed on the Work Order object to store the generated token. To do so, create a Text Area (Long) field to store the entire token.
Go to Setup > Object Manager > Work Order.
Click on Fields & Relationships > New.
Select Text Area (Long) as the field type.
Name the field (e.g.,
Form Token
) and set the length to the maximum value (131,072
characters).Save the field.
This field will store the full token returned by the flow.
Step 2: Configure a Record-Triggered Flow
Go to Setup > Flows > Click New Flow
Choose Start From Scratch and click Next
Choose Record-Triggered Flow and click Create
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 |
Step 3: Add the Action to Generate the Form Token
Add an Action element
Search for
Sharinpix__GenerateFormTokenAutomation
On the Action modal for
Sharinpix__GenerateFormTokenAutomation
, populate the fields as indicated below:
Field | Example Value |
---|---|
Form Template ID | Fire Safety Inspection |
Record ID | Triggering WorkOrder > Work Order ID |
Expiry in Days | 10 |
Name Field API Name | WorkOrderNumber |
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 (
0
). 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.
Step 4: Add Update Element
This step is used to store the token generated by the Apex action into the custom field FormToken__c
you created on the Work Order.
Add an Update element
Select Use the Work Order record that triggered the flow
Do not add any filter conditions.
In the Set Field Values for the Work Order Record section, populate it as indicated below:
Field | Value |
---|---|
FormToken__c | Outputs from sharinpix__GenerateFormTokenAutomation.token |
Step 6: Find the SharinPix Token
To test the flow, create or update a Work Order record.
After the flow runs, the generated SharinPix Form Token will be stored in the FormToken__c
field of the Work Order. You can view it directly from the record detail page to confirm that the token was generated successfully.
Form Token Use Case Example: Using a Field Service App Extension to Open a SharinPix Form
You can set up a Field Service App Extension to launch the forms from the Field Service mobile app and directly access them in the SharinPix Mobile App by embedding the form token in a SharinPix deeplink or URL.
The format for deeplinks to open a form in the SharinPix app is as follows:
sharinpix://form?token=<sharinpix-token>&host=app.sharinpix.com
The format for universal links (URL) to open a form in the SharinPix app is as follows:
https://app.sharinpix.com/native_app/form?token=<sharinpix-token>&host=app.sharinpix.com
- The section,
<sharinpix-token>
, in the above deeplink and universal link formats, should be replaced by the form token. - For more information on how to configure Field Service App Extensions with SharinPix deeplinks/URLs, please refer to this documentation: Integration of SharinPix App with SFS (FSL) App using App Extension
0 Comments
Add your comment