SharinPix DocumentationFAQ Misc QuestionsI got an empty token value, what could be the cause and how to correct it?

I got an empty token value, what could be the cause and how to correct it?

Some common causes leading to an empty SharnPix token value are:

  • Automations such as Process Builder or Flows that block proper generation of the token.


  • Users attempting to generate a SharinPix token without having proper access to the SharinPix token field.

In cases involving the token generation via an automation such as a Process Builders or Triggers, the user launching them should have edit access rights on the SharinPix Token field.


  • Creation SharinPix token fields before activation of the automation that populates such fields with a token.

It could happen that a record containing the SharinPix Token field has been created before the activation of the automation or during a deactivation of the automation. In such cases, the SharinPix Token field will not be populated with the generated token. Here, the token should be generated automatically. The next section details how you can manually generate a token on a record. 


  • It may also happen that users accidentally delete the token value in the fields. Therefore, we recommend the activation of Field History Tracking to keep track of changes that might have taken place in such fields.

How to manually generate a token? (Some developer skills required)

By modifying your current Process Builder

If your Process Builder triggers the token generation only at the creation of the record to generate the missing token, you simply need to:

  • Modify your Process Builder so that it triggers when a record is being updated instead of on its creation
  • Then, go to the record having the missing token
  • Perform a simple update on the same record in order to trigger the Process Builder so that it performs the token generation. You can just click on the Edit button followed by the Save button for the update.
  • Finally, revert the modification on your Process Builder so that it triggers upon the creation of records again

If your Process Builder is already configured to be triggered upon the update of the records, then you simply need to perform a simple update on the record missing the token in order to generate the token. No need to modify the Process Builder in this case. 

Using the TokenGeneration Apex class

To manually generate a SharinPix token, you can make use of the Apex class TokenGeneration available in the SharinPix package.

Follow the steps below to do so:

  • Open your Developer Console
  • Click Debug | Open Execute Anonymous Window to open the Enter Apex Code window
  • Then, execute the following code snippet:
List<sharinpix.TokenGeneration.Parameters> paramsList = new List<sharinpix.TokenGeneration.Parameters>();
sharinpix.TokenGeneration.Parameters param = new sharinpix.TokenGeneration.Parameters();      
param.recordId = '<Enter Your Record ID>';
param.fieldname = '<Enter the SharinPix Token Field API name>';
paramsList.add(param);
sharinpix.TokenGeneration.createToken(paramsList);

Note:

The recordId parameter refers to the record ID on which you want to generate the token and the fieldname parameter refers to the SharinPix token field in which you want to store the generated token.

These two parameters (that is, recordId and fieldname) are required and therefore should always be populated.

There are two more variables which are available in the available in the TokenGeneration class, namely:

  • name - which can be used to reference the record name (or number) inside the token.
  • numberOfHours - 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.

The name and numberOfHours parameters are not required by default. If you want to make use of these two additional parameters as well, here is how the code should be like:

List<sharinpix.TokenGeneration.Parameters> paramsList = new List<sharinpix.TokenGeneration.Parameters>();
sharinpix.TokenGeneration.Parameters param = new sharinpix.TokenGeneration.Parameters();      
param.recordId = '<Enter Your Record ID>';
param.fieldname = '<Enter the SharinPix Token Field API name>';
param.name = '<Enter the Field Name>';
param.numberOfHours = 2;
paramsList.add(param);
sharinpix.TokenGeneration.createToken(paramsList);

If you need assistance in generating missing token on existing records, kindly contact SharinPix Support team on:

[email protected]

0 Comments

Add your comment

E-Mail me when someone replies to this comment