SharinPix DocumentationFAQ Misc QuestionsHow can I calculate the number of images in a SharinPix Album and store the count in a Salesforce field?

How can I calculate the number of images in a SharinPix Album and store the count in a Salesforce field?

This section demonstrates how to keep track of number of images added to a SharinPix album and store the count in a Salesforce field automatically.

For this to be done, we will take advantage of SharinPix Image Sync to track the image count. 

Indeed, when Image Sync is used on an object, a related SharinPix Image record is created whenever an image is uploaded to the object's SharinPix album. The number SharinPix Image records created can then be used to count the number of images uploaded to the album.

There are two ways to track the number of images uploaded to a SharinPix album:

  1. By using a Rollup Helper from the AppExchange.
  2. Or by using a Process Builder to update the count and the Salesforce field. 

However the second option comes with a limitation since Process Builders do not cater for record deletion. Therefore, if an image is deleted, the count cannot be updated accordingly using a Process Builder. Hence, if you want to cater for deletion as well, it is better to go with Rollup Helpers.

Note:

In both cases, Image Sync should be set up for the object on which you intend to keep an image count.

You can refer to the following article for detailed information about how to setup Image Sync for an object:

Setup SharinPix Image Sync

For this demo, we will use the Account object since the SharinPix package includes SharinPix Image Sync setup for the Account object by default. 

However, you should make sure that the option Enable Image Sync is checked for the SharinPix album added on the Account object.

Using a Rollup Helper

Rollup Helpers are available on the AppExhange. They usually provide an interface to easily create new rollups without any coding. 

With a Rollup helper, we can therefore create data rollups by using the Account object and the SharinPix Image object. In this case, the Account object will act as the parent object on which the rollup results (that is, the image count) will be made available in a Salesforce field and the SharinPix Image will act as the child object from which the data for the image count will be obtained.

Tip:

For more information about Rollup Helpers and how they can be used to create data rollups, refer to the following article:

https://www.passagetechnology.com/rollup-helper-admin-guide

Using a Process Builder

Before creating the Process Builder, you will need to create a field that will store the count. Therefore, go on the Account object and create a new field with:

  • The Number data type
  • Image Count as label
  • A default value of 0

Now that Image Sync has been setup and our new field created, we can go ahead and create the Process Builder.

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:
    1. For the field, Process Name enter SharinPix Album Image Count on Account Object
    2. Enter a description for the process. (This step is optional)
    3. For the field, The process starts when select A record changes
    4. Click Save

Once on the Process Builder editor:

  • Click on Add Object
    1. For the field Object, select SharinPix Image
    2. For the field Start the process, choose only when a record is created
    3. Click on Save
  • Click on Add Criteria
    1. For the field Criteria Name, enter No Criteria
    2. For the field Criteria for Executing Actions, choose No criteria—just execute the actions!
    3. Click onSave
  • Click on Add Action
    1. For the Action Type field, choose Update Records
    2. For the Action Name, enter Update Image Count
    3. For the Record Type, select Select a record related to the sharinpix__SharinPixImage__c. Then from the dropdown menu, select Account
    4. Click on Choose
  • Leave Criteria for Updating Records on No criteria—just update the records!
  • Inside the Set new field values for the records you update section:
    1. For the Field, select Image Count
    2. For the Type, select Formula
    3. For the Value, click on Build a formula 
    4. Inside the formula builder, use the following formula:

[sharinpix__SharinPixImage__c].sharinpix__Account__r.Image_Count__c + 1

       5. Click on Use this Formula

  • Click on Save when done

You can now activate the Process Builder.

Demo

To test this new implementation:

  • Go to an Account record
  • Upload an image to the SharinPix album
  • Check if the field Image Count has been updated accordingly

0 Comments

Add your comment

E-Mail me when someone replies to this comment