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.
This article demonstrates how to create a Process Builder that will generate and store a SharinPix mobile app tokens to upload images onto an album upon creation of records.
To do this, we will:
To access online features such as view 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:
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:
- By creating a single field of type Long Text Area that will store the token.
- 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
As Formula in Salesforce don't support Long Text Area field, we suggest to create 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 FSL mobile App.
If you don't need the token to be part of a formula field, please ignore all the part of this article including reference to those fields and only focus on the Single SharinPix token field as per pervious chapter.
Create three fields, of data type Text(255) and field labels:
- SharinPix Token 1
- SharinPix Token 2
- SharinPix Token 3
Creation of the the Process Builder
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 user-defined field(s).
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.
This section demonstrates how to create a Process Builder that invokes the apex class TokenGeneration in order to generate a token for newly-created Work Order records.
To do so, follow the steps below:
- Go to Setup. In the Quick Find Box, type Process Builder.
- Under Process Automation, select Process Builder.
- Click on New.
- For the newly-created Process Builder:
- Process Name: Token Generation for Work Order Object
- Enter a description for the process. (This step is optional)
- The process starts when: A record changes
- Click Save
When the Process Builder opens:
- Click on Add Object.
- For the field Object, select Work Order.
- For the field Start the process, choose only when a record is created.
- Click Save.
- Click on Add Criteria.
- For the field Criteria Name, enter No Criteria.
- For the field Criteria for Executing Actions, choose No criteria—just execute the actions!
- Click on Add Action.
- For the Action Type field, choose Apex.
- In the field Action Name, enter Token Generation (or any other name of your choice).
- For the Apex Class field, choose sharinpix__TokenGeneration.
- Inside the Set Apex Variables section:
- For the field Record ID, select Field Reference as the Type. For the Value, choose Work Order ID.
- For the field Field API Name(s), select String as the Type. For the Value, enter SharinPix_Token__c
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 Process Builder to work as expected, you must ensure that:
- Each API name is typed correctly in the Field API Name(s) section.
- The API names should be separated by a semi-colon as shown below:
There are two more variables which are available inside the Set Apex Variables, namely:
- Record Name - which can be used to reference the record name (or number) inside the token.
- Hours Before Token Expires - which can be used to set the number of hours before the token expires. This variable has a type Number and only takes integers as value. For example, if you want the token to expire in 3 hours, just enter 3 in the Value field.
These two variables are optional and can be accessed by clicking on the Add Row link inside the Set Apex Variable section.
- The variables Record ID and Field API Name(s) are compulsory and should therefore be filled.
- The variables Record Name and Hours Before Token Expires are optional and can therefore be ignored when not required.
5. Click Save when done.
6. Activate the process.