Blog

The Salesforce mantra is ‘clicks not code’ so we always look for a config solution to a problem before resorting to code. While we can set the unique indicator on a custom field to prevent duplicate values for one field across records, how do we prevent records inserted with duplicate values across all or some of the fields? Do we need to write a trigger to handle this? Or is there a config only solution to the problem?

Its actually very simple and can be accomplished in 2 steps:

  1. Define a unique Text field on the object
  2. Create a workflow rule and field update to update the text field with a concatenation of values

In this example, we are using a custom object ‘Transaction’. The Transaction object has lookups to Account and Product and a Transaction Date and Amount. We want to make sure that no duplicate transactions for the same Account, Product, Transaction Date and Amount can be saved.

Transaction Fields

To setup our config duplicate check, we follow step 1 and add a custom field ‘Unique Record Key’ to the Transaction object. Note that it is marked as Unique. The type and length is defined as Text 100. This should be more than enough as it is holding 2 id fields, a date and an amount.

Unique Record Key Custom Field

Next we need to add a workflow rule. The rule criteria is ‘True’ and the evaluation criteria is set to created and every time edited, to make sure that it will always fire for new and for any edits to existing records.

Unique Record Key Workflow

The field update concatenates the values of the Account Id, Product Id, Transaction Date and Transaction Amount and updates the Unique Record Key with the result. Notice that the non text fields need to use the TEXT function to convert them to text to be able to use the concatenate function.

Workflow Field Update

Here we see the Unique Record Key added temporarily to the page layout, so we can see that the field update is working. You can see the two id values, followed by a date and an amount. Don’t forget to remove the field from the page layout!

Unique Record Key on Page Layout

Finally here is the result we are looking for! We have prevented a duplicate record with Salesforce config only. Attempting to add a record with exactly the same values for Account, Product, Transaction Date and Amount will result in an error. The error message tells us there is a duplicate value on another record, and even gives us the record name and a link to the record to check it.

Duplicate Transaction

What Certification are you studying for now?

Focus on Force currently provides practice exams and study guides for sixteen certifications

Preventing Duplicate Records with Salesforce Config

The Salesforce mantra is ‘clicks not code’ so we always look for a config solution to a problem before resorting to code. While we can set the unique indicator on a custom field to prevent duplicate values for one field across records, how do we prevent records inserted with duplicate values across all or some of the fields? Do we need to write a trigger to handle this? Or is… Read More

Preventing Duplicate Records with Salesforce Config

Salesforce Case Management

In most every company which prides itself on taking care of its customer base to the fullest, the Salesforce native functionality of Case Management goes hand in hand with customer success. The departments in an organization that deal with customer service, product support, issue resolution and service requests can all benefit from utilizing the case management functionalities; and related automation options; within Salesforce. As described in Salesforce Service Cloud Overview … Read More

Salesforce Case Management

Using DataLoader with Lookup Fields

External Ids provide a convenient way to integrate data from an external system, by allowing the use of a unique record identifer for records instead of the Salesforce Id. For example, you may define an Account Code external id on the Account object, which is the unique key for an account record in an ERP system that is integrated with Salesforce. When using DataLoader or another integration tool to update… Read More

Using DataLoader with Lookup Fields

Salesforce Mass Email

When you hear that Salesforce has a mass email capability you may think that you don’t need a marketing automation package to do that for you. Dig a little deeper and you will find that although Salesforce can send mass emails, there are a number of limitations that may have you looking back at AppExchange products. Firstly, lets look at what you can do with Salesforce mass email capability. You… Read More

Salesforce Mass Email

Quick Start Guide to using Conga Composer with Excel

Conga Composer is one of the most widely used 3rd party AppExchange apps for document generation with Salesforce. It can be used to merge Salesforce data to produce documents in Word, Excel, Powerpoint, HTML Email and PDF format. Here is a quick guide to generating an Excel spreadsheet with data from Salesforce. Create Your Excel Template Define the Fields and Reports it will use Add Merge Fields to the Excel… Read More

Quick Start Guide to using Conga Composer with Excel

How to Delete Multiple Records from a Salesforce Related List

You may be faced with the situation where you need to be able to delete multiple records from a related list in one click. Standard related lists do not have a feature to select all and delete all selected records. The standard way to delete from a related list is to use the del link and delete each record individually. This can be very time consuming and tiresome if there… Read More

How to Delete Multiple Records from a Salesforce Related List

Salesforce Cross Filter Report Examples

You may have come across cross filters when learning about Salesforce reports but having no immediate need for them, forget about them. It is only sometime later when faced with a reporting challenge that you may delve back and find that they are very useful and may even solve a problem that you thought you could not do with Salesforce reports. Lets review what reports with cross filters can do:… Read More

Salesforce Cross Filter Report Examples

Salesforce Email Templates

When you send an email from Salesforce, such as when you use the Send Email button or triggered from a workflow, you can select an email template. Email Templates in Salesforce come in four different types: Plain Text HTML using Letterhead HTML Custom Visualforce Plain Text Email Template This is the simplest email template to create. You can create it very quickly by entering the email text and including the… Read More

Salesforce Email Templates

Salesforce Lead Conversion

I was looking for a process flow diagram, that describes what happens when a lead is converted in Salesforce. I couldn’t find one, so I made my own. Once a lead is qualified, the next step is to convert the lead. In Salesforce, when you convert a lead, there are a number of options that are part of the process flow. The first step is to press the convert button…. Read More

Salesforce Lead Conversion

How to Display a Traffic Light Indicator in Salesforce

Visual indicators are a great addition to a Salesforce page to highlight important information or values. Instead of just displaying a value, showing an image will make a much larger impact. Depending on the situation, it may be more suitable to just display a single indicator such as a caution or stop image, or if a variable can have a range of values, display a variable image according to which… Read More

How to Display a Traffic Light Indicator in Salesforce

Salesforce Platform Overview

There are a number of features and functionality that are part of the Salesforce platform and are available to all Salesforce solutions. They offer the technology or functionality that can be used either standalone (e.g. content management) or used to build upon (e.g. force.com code). As they are common across the different Salesforce applications (e.g. Sales Cloud, Service Cloud and custom applications) they are part of the Salesforce platform. The… Read More

Salesforce Platform Overview

Salesforce Activities Tab and List View

  You may wonder where the Activities tab is in Salesforce, so you can see a list view of activities. You can see the task list and calendar on the home page but what if you would like to see all of your tasks and events in a list. Well there is a way to get to a list view, but it is easy to overlook. In the calendar section… Read More

Salesforce Activities Tab and List View

Salesforce and Email – What are the options?

When it comes to Salesforce and email, it can get confusing to understand what the options are. Read on to discover 10 ways you can work with email and Salesforce together. Sending Email from Salesforce Some people may wonder whether integration to an email client such as Outlook is even necessary. If Salesforce could send and automatically process incoming emails, then couldn’t users just live in Salesforce and use it… Read More

Salesforce and Email – What are the options?

Salesforce URL Hacking

You may find yourself with the requirement to create a record from a related list and populate a number of fields. By default, Salesforce will populate the field on the related record that links the two objects, but no other fields. For example, if you create a record for a custom object related to an opportunity, the custom record will have the opportunity populated as it relates the two records,… Read More

Salesforce URL Hacking