Form Utils Methods

Overview

The SharinPix package provides the Apex class, FormUtils, which are utility methods for use for the Form Feature.

The Form Utils methods include:

Prerequisites:

  • The SharinPix Package with version 1.342 (or above) should be installed; refer to the article below to upgrade your current package:  How to upgrade SharinPix package

  • The SharinPix Forms permission set should be assigned to users using the form utils methods.

Form Utils Methods Example

generateToken

global static String generateToken(String recordId, String templateId, Map<String, Object> options)

  • This method generates a SharinPix Form Token with specific abilities. Below is a detailed description of each parameter:

    • recordId (String)
      The unique identifier of the record associated with the form. This parameter specifies which record the generated token will be linked to. For example, if the form pertains to a specific account or case, you would pass that record's ID here.
    • templateId (String)
      The identifier of the form template to be used for token generation. Ensure the templateId corresponds to the desired form template in your system.
    • options (Map<String, Object>)
      A key-value map that provides additional configuration options to customize the form's behavior. This parameter is optional and allows flexibility in defining extra settings. Common examples include:
      • nameFieldApiName: Specifies the API name of the field used to display a recognizable name for the form (e.g., a contact’s name or an opportunity title).
      • formExpiry: Defines the expiration date or duration for the form's validity. The formExpiry takes a number as value indicating the number of days after which the form will expire.
         
Map<string, object> options = new Map<string, object> {
     'nameFieldApiName' => 'WorkOrderNumber',
     'formExpiry' => 8
};

String token = sharinpix.FormUtils.generateToken('0018a00001rL2scAAC', 'a0Ral000007iSvpEAE', options);
System.debug(token);
Click to copy

generateUrl

global static String generateUrl(String recordId, String templateId, Map<String, Object> options)

  • This method generates a SharinPix Form Url (Universal Link), which opens the specific form template on the SharinPix Mobile App. Below is a detailed description of each parameter:
    • recordId (String)
      The unique identifier of the record associated with the form. This parameter specifies which record the generated token will be linked to. For example, if the form pertains to a specific account or case, you would pass that record's ID here.
    • templateId (String)
      The identifier of the form template to be used for token generation. Ensure the templateId corresponds to the desired form template in your system.
    • options (Map<String, Object>)
      A key-value map that provides additional configuration options to customize the form's behavior. This parameter is optional and allows flexibility in defining extra settings. Common examples include:
      • nameFieldApiName: Specifies the API name of the field used to display a recognizable name for the form (e.g., a contact’s name or an opportunity title).
      • formExpiry: Defines the expiration date or duration for the form's validity. The formExpiry takes a number as value indicating the number of days after which the form will expire.
Map<string, object> options = new Map<string, object> {
     'nameFieldApiName' => 'WorkOrderNumber',
     'formExpiry' => 8
};

String url = sharinpix.FormUtils.generateUrl('0018a00001rL2scAAC', 'a0Ral000007iSvpEAE', options);
System.debug(url);
Click to copy

0 Comments

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.