# SharinPix automatic mobile upload token generation (Admin Friendly)

This article demonstrates how to generate SharinPix tokens allowing ***image upload using the SharinPix mobile app only***. Such token configuration is solely used for mobile uploads and not for album display.

## Overview

This article demonstrates how to create a Salesforce Flow that will generate and store SharinPix mobile app tokens to upload images onto an album upon the creation of records.

To do this, we will:

* [Create the SharinPix Token field(s) that will store the token generated](#creation-of-the-sharinpix-token-field-s)
* [Create the Flow](#creation-of-the-flow)

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

To access online features such as **viewing** SharinPix albums, specific SharinPix images, and SharinPix search within the SharinPix mobile app, the SharinPix app **online mode** can be used. For more information on how to make use of the online mode feature, refer to the following article:

[SharinPix Mobile App: Online mode](https://docs.sharinpix.com/documentation/mobile-app/sharinpix-mobile-app-online-mode)
{% endhint %}

## Creation of the SharinPix Token field(s)

For this demo, we will use the **Work Order** object. Firstly, we need to create fields that will store the token generated. You have two ways of doing this:

1. By creating a single field of type **Long Text Area** that will store the token.
2. By creating multiple fields of type **Text Area (255)**. In this case, the token will be split into chunks of a maximum of 255 characters. Each chunk will be then stored in the fields.

### 1. Creation on a single field to store the SharinPix Token

Create a field named **SharinPix Token** of type **Long Text Area** on the Opportunity object.

### 2. Creation of multiple fields to store the SharinPix Token

{% hint style="success" %}
As Formula in Salesforce doesn't support Long Text Area field, we suggest creating 3 fields of type **Text Area(255)** to support the token also in Formula. However, those should not be needed if you are using the token in the Field Service mobile app.

*If you don't need the token to be part of a formula field* , please ignore all the parts of this article including references to those fields, and only focus on the single SharinPix token field of type Long Text Area field.
{% endhint %}

Create three fields, of data type **Text(255)** and field labels:

1. SharinPix Token 1
2. SharinPix Token 2
3. SharinPix Token 3

## Creation of the Flow

{% hint style="info" %}
The SharinPix package includes the class **TokenGeneration** which contains a method that can be used to generate a token for an object. Using this method, the token generated can be automatically stored inside the user-defined field(s).
{% endhint %}

{% hint style="warning" %}
For the rest of the demo, we will use single field **SharinPix Token** , instead of **SharinPix Token 1**, **SharinPix Token 2** , and **SharinPix Token 3** to store the token.
{% endhint %}

This section demonstrates how to create a Flow that invokes the apex class **TokenGeneration** in order to generate a token for newly-created/updated Work Order records.

To do so, follow the steps below:

* Go to Setup. In the Quick Find Box, type **Flows**.
* Under **Process Automation** , select **Flows**.
* Click on the **New Flow** button.
* Select the option **Record-Triggered Flow** , and click on the **Create** button.

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2FJKsBNL8bHhrpfoVxxVfR%2FSharinPix%20automatic%20mobile%20upload%20token%20generation%20(Admin%20Friendly)%20-%201.png?alt=media&#x26;token=2a450f3c-814a-4af4-805a-392e7b418f61" alt=""><figcaption></figcaption></figure>

* After clicking on *Create* , the *Configure Start* modal will be displayed. Fill in the modal as indicated below:
  * **Select Object** : Work Order
  * **Configure Trigger** : A record is created or updated
  * **Set Entry Conditions** : None
  * **Optimize the Flow for** : Actions and Related Records
* Click on **Done** to save the configurations.

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2FFDNPpBPF6UCqWaoleU17%2FSharinPix%20automatic%20mobile%20upload%20token%20generation%20(Admin%20Friendly)%20-%202.png?alt=media&#x26;token=f8a98c7e-3be5-4b26-a1af-553566aee93a" alt=""><figcaption></figcaption></figure>

* Next, add an **Action** element.

{% hint style="warning" %}
**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 %}

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2FTNtpLl2U4EuXq0MxwbCH%2FSharinPix%20automatic%20mobile%20upload%20token%20generation%20(Admin%20Friendly)%20-%203.png?alt=media&#x26;token=c2ca2b0b-bc0d-4ec7-92e6-0376bbfa8bd5" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2FmAH3NYOoq9xrg02dKFZe%2FSharinPix%20automatic%20mobile%20upload%20token%20generation%20(Admin%20Friendly)%20-%204.png?alt=media&#x26;token=13c3e3df-6693-485e-8e0c-b3764fe5b1b1" alt=""><figcaption></figcaption></figure>

* On the \_Action \_modal, use the search bar to find the **sharinpix\_\_TokenGeneration** Apex class.
* Click on **sharinpix\_\_TokenGeneration**.

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2FjKB7hdtKWp9IO11bbYBg%2FSharinPix%20automatic%20mobile%20upload%20token%20generation%20(Admin%20Friendly)%20-%205.png?alt=media&#x26;token=0da0ccd7-cd86-4bcd-b893-c5dbed9e99ff" alt=""><figcaption></figcaption></figure>

* On the \_Action \_modal for *sharinpix\_\_TokenGeneration* , populate the fields as indicated below:
  * **Label:** Generate Mobile Upload Tokens
  * **Description:** Enter a description (optional)
  * **Field API Name(s)** : SharinPix\_Token\_\_c
    * *Note: This is a mandatory field and refers to the SharinPix token field API name.*
  * **Record ID:**{!$Record.Id}
    * *Note: This is a mandatory field and refers to the current Work Order record Id.*

{% hint style="warning" %}
If you are using multiple fields to store the token, please note that:

* The token generated is split and stored into the fields **SharinPix Token 1** , **SharinPix Token 2**, and **SharinPix Token 3**.
* The values **SharinPix\_Token\_1\_\_c** , **SharinPix\_Token\_2\_\_c,** and **SharinPix\_Token\_3\_\_c** refer to the field API names used to store the token generated.
* For the Flow to work as expected, you must ensure that:
  1. Each API name is typed correctly in the **Field API Name(s)** section.
  2. The API names should be separated by a semi-colon as shown below:

&#x20;         **SharinPix\_Token\_1\_\_c**;**SharinPix\_Token\_2\_\_c;SharinPix\_Token\_3\_\_c**
{% endhint %}

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2F5Cmg0rVsfPndF2091djO%2FSharinPix%20automatic%20mobile%20upload%20token%20generation%20(Admin%20Friendly)%20-%206.png?alt=media&#x26;token=1e25546e-c6c3-48c5-80ea-6766ae6cac0a" alt=""><figcaption></figcaption></figure>

There are other **optional** variables that are available in the \_Action \_modal, namely:

* **Custom Permission ID or Name:** ID or Name of the **SharinPix Permission** object (of type **Mobile Launcher**) to be used for opening the SharinPix Mobile App.
* **Hours Before Token Expires:** This can be used to set the number of hours before the token expires. This variable has a type **Number** and only takes **integers** as values. For example, if you want the token to expire in 3 hours, just enter 3 in the **Value** field.
* **Record Name**: This can be used to reference the record name (or number) inside the token.

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

* If you do not want the tokens to expire, do not fill in the **Hours Before Token Expires** parameter.
* If you want the token to expire after a specified number of hours, ensure that you provide enough time before the token expires as expired tokens are no more valid and cannot be used to upload photos.
  {% endhint %}

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2F8Xah1cOEih8qqbibZf40%2FSharinPix%20automatic%20mobile%20upload%20token%20generation%20(Admin%20Friendly)%20-%207.png?alt=media&#x26;token=e0194dc4-e9bd-4b66-b2c8-d9a519ca8cdf" alt=""><figcaption></figcaption></figure>

5\. Click **Done** to save the *Action* configurations.

6\. Save the Flow and activate it.

## Find the SharinPix Token

Using the above Flow, tokens are generated/updated for all Work Order records created/updated.

The SharinPix Token can be found inside the **SharinPix Token** field of the newly-created/updated Work Order records.

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2FEppJJSZidyBnrY5Rfw3j%2FSharinPix%20automatic%20mobile%20upload%20token%20generation%20(Admin%20Friendly)%20-%208.png?alt=media&#x26;token=f1ca2465-5c44-429d-a8d3-d7213f1da299" alt=""><figcaption></figcaption></figure>
