Display an image in Salesforce fields using Process Builder

This article demonstrates how to add the latest image uploaded to a SharinPix Album in Salesforce fields.

This can be done by:

  • Adding an image to a Rich Text field using a Process Builder and Image Sync
  • Using a Process Builder with Image Sync to display an image in a Formula field 

Note:

In both cases, Image Sync should be set up for the object you intend to use.

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 Process Builder to add an image to a Rich Text field

Create the Rich Text field

Before creating the Process Builder, we need to create a field that will display the image. Therefore, go on the Account object and create a new field with:

  • Data type: Text Area (Rich)
  • Field Label: Image

Create the Process Builder

Now that Image Sync has been setup and our new Rich Text 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 Add Image to Rich Text Field on Account
    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 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 on Save
  • Click on Add Action
    1. For the Action Type field, choose Update Records
    2. For the Action Name, enter Update Account Record
    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 the Rich Text field created previously, that is Image
    2. For the Type, select Formula
    3. For the Value, click on Build a formula 
    4. Inside the formula builder, use the following formula:

"<img src=\"" & [sharinpix__SharinPixImage__c].sharinpix__ImageURLThumbnail__c  & "\" />"

The above formula makes use of the field [sharinpix__SharinPixImage__c].sharinpix__ImageURLThumbnail__c which stores the image's URL in a thumbnail format on the SharinPix Image object.

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 displays the image accordingly

Using Process Builder to display an image in a Formula field

Create the Salesforce field

In this section we will proceed using the following:

  • Create a Salesforce field to store the image URL
  • Create a Formula field to display the image
  • Create a Process Builder that will use Image Sync to update the URL field whenever an image is uploaded

For this implementation, you need to create the following field:

  1. A field of type URL to store the image URL generated:
    • Data Type: URL
    • Field Label: First Image URL
  2. A Formula field which will use the image URL stored in the field created above (that is First Image URLto display the image. For the formula field:
    • Date Type: Formula
    • Field Label: First Image
    • Formula Return Type: Text
    • Formula:

IF( ISBLANK( First_Image_URL ), "Image Not Found", IMAGE(  First_Image_URL, ""  ) )

Create the Process Builder

Now that Image Sync has been setup and our new Rich Text 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 Add an Image to Field on Account
    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 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 on Save
  • Click on Add Action
    1. For the Action Type field, choose Update Records
    2. For the Action Name, enter Update Account Record
    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 the URL field created previously, that is First Image URL
    2. For the Type, select Field Reference
    3. For the Value, choose Image URL Thumbnail
  • Click 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 Image and First Image URL fields have been populated correctly as demonstrated below:

Tip:

The methods mentioned above have a limitation, they cannot be used to display multiple images in one field.

However, SharinPix  provides a component (the SharinPix To Rich Text Area component) that perform the same process and which can be used to add multiple images in one field.

The SharinPix To Rich Text Area component allows users to select and send one or more images from a SharinPix album to a Rich Text field. This method is easier to configure and provides more flexibility.

For more information about this component, please refer to the following article:

SharinPix To Rich Text Area

0 Comments

Add your comment

E-Mail me when someone replies to this comment