fosstodon.org is one of the many independent Mastodon servers you can use to participate in the fediverse.
Fosstodon is an invite only Mastodon instance that is open to those who are interested in technology; particularly free & open source software. If you wish to join, contact us for an invite.

Administered by:

Server stats:

9.9K
active users

#usecases

0 posts0 participants0 posts today

🤖 Nächste Stufe der #Robotik: Durch Verzahnung mit #KI-Methoden wie dem maschinellen Lernen werden #Roboter lernfähig. Daraus entstehen neue Einsatzfelder, etwa in #Kreislaufwirtschaft, #Pflege oder #Handwerk. Anhand von #UseCases zeigen wir in einem neuen Whitepaper, wo Roboter künftig unterstützen können und welche Herausforderungen noch bestehen.
Zum Whitepaper 👉 plattform-lernende-systeme.de/

Keep Salesforce Data Clean With Before Save Flows

Data quality is essential for every Salesforce administrator, as it influences reporting accuracy, decision-making, and overall user confidence. With users constantly inputting data through multiple interfaces, maintaining clean, standardized field values is an ongoing challenge. Fortunately, Salesforce provides tools like validations, reports, batch updates, workflow rules, and processes to help manage data consistency. The introduction of before-save flows in the Spring ’20 Release has transformed data handling, allowing admins to update field values as records are created or modified—without needing complex code. This guide will explore how before-save flows can help streamline data entry, reduce errors, and ensure clean, accurate field values across all data channels.

There are several tools available in Salesforce to ensure clean data:

  • Validations
  • Reports
  • Batch updates
  • Workflow rules
  • Flows
  • Code

Salesforce administrators have the functionality to update field values by triggering a before-save flow when a record is created and/or updated. Admins do not need to write code to start the update.

Understanding The Before-Save Flow Execution

Before we go into the details of the use case and the solution, let’s dissect and understand what this all means. When a user creates or updates a record there are several steps that are executed while the data is being written to the database. When we use popular automation tools and trigger an update on the fields, what typically happens is that the data the user provides is saved, and then overwritten based on the automation rules that are implemented in the system. This update method is not very fast, and presents several potential complications: Duplicate rules can kick in based on the data that is initially entered into the system and produce unexpected results, although the final data saved based on the active automation rules may not trigger the same duplicate rule.

Advantages of Before-Save Flow Updates

Before-save updates are executed before the data is saved; very early in the order of execution. This makes them very fast, and also more predictable because there is a lower chance that they produce unexpected results interacting with other automation rules.

Another advantage of before-save updates is that they are executed regardless of what channel the update is coming from. You may have internal users entering data on Salesforce. You may also have external users entering data on a flow that runs on a digital experience (community) site. If you use field validation rules, you will need to set them up separately on all channels. When you set up a before-save flow update, on the other hand, it will be executed whenever the data is entered and/or updated regardless of the channel.

Examples of Before-Save Flow Applications

🚨 Use Cases 👉🏼 What is this solution good for?

  • Clean special characters from phone field entry on the contact
  • Update custom record name combining several field values on the same object
  • Update accounts based on employee count and categorize them by Small/Medium/Large

Main limitations:

  • The flow operations that can be performed are limited (please see the image).
  • Before-save flows can not perform create or update operations on the related objects and their fields.

Clean Special Characters From Phone Entry

I built a solution for volunteers to check-in on a digital experience site using their mobile phone number. One potential issue with this flow is that the users enter phone numbers into the system in various formats. For example, these entries are very common:

  • 5555555555
  • 555 555 55 55
  • (555) 555-5555

You can easily write a SUBSTITUTE formula to strip the special characters and spaces out of these entries.

This means that you can build a very simple formula to take the phone data entry value, and replace it with a new value before it is committed to the database. The new value will be in the format of the first bullet above.

The Flow

Start a record-triggered before save flow.

The flow consists of two elements only: The start element and one assignment element. Please remember that there is no need for a get or update element. We are working with the value that is entered on the screen and assigning a value to what will be written to the database.

Please note that I recommend using the update element before save instead of the assignment element currently, although the functionality is the same.

The flow is short and simple.

The first step on our flow will be to adjust the settings on the start element. When the start element is double-clicked, the flow editor displays several settings that can be adjusted. In this example, we would like to launch our flow when a contact record is created or updated to make fast field updates.

The second element in the flow is a simple assignment element. {!Record.MobilePhone} refers to the mobile phone field on the contact record that the user is about to create or update. This step assigns a formula value to the mobile phone field.

The Formula

Here is the {!CleanMobilePhone} formula:

SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE({!$Record.MobilePhone} , "(", ""), ")", ""), " ", ""), "-", "")

It is a simple formula that finds the ()- and space characters in a string and removes them.

The Result

When this flow is saved and activated, it updates all mobile phone entries before they are saved to the database. The field value will only consist of digits. Please remember that Salesforce formats the phone fields for display purposes on the screen. You will see (555) 555-5555 displayed on the screen, but when you go to edit the field, you will find out that the value only includes digits.

Enjoy.

Explore related content:

Popular Validation Rules for Salesforce Flows including Phone, Email and Address Fields

6 Things You Can Do With The Transform Element

Create by Checking a Matching Record in Flow

Popular Validation Rules for Salesforce Flows including Phone, Email and Address Fields

Salesforce Flow validation rules are essential for ensuring data accuracy and consistency in automated workflows. By setting specific conditions that data must meet before it is saved or processed within a flow, these rules prevent erroneous or incomplete information from moving forward in the workflow. For instance, you might create a validation rule that requires certain fields, such as phone, email and address, to be filled out or ensures that a value falls within a specified range before the flow can continue. This not only enforces data quality standards but also helps avoid downstream errors that could disrupt business processes or lead to poor decision-making. With flow validation rules, Salesforce admins can maintain control over data integrity while enhancing user experience by proactively catching errors.

Below are a few popular flow validation rules I used in my projects

Name

Standard length for Name Fields is 40 for First Name, 20 for Middle Name and 80 for Last Name.

First Name

Error message:

Your entry needs to be shorter than 40 characters.

Validation rule:

LEN({!First_Name})<=40

Social Security Number (USA)

Error message:

Please enter 9 digits for the SSN field.

Validation rule (this rule allows for dashes):

OR( REGEX( {!Social_Security_Number} , "[0-9X\-]{11}"), REGEX( {!Social_Security_Number} , "[0-9]{9}") ) 

Address

Standard length for address fields are 256 for Street Address and 80 for City. The ZIP (Postal) code can be in XXXXX or in XXXXX-XXXX format (USA).

State Code

Error message example:

Please enter a State Code consisting of two capital letters.

Validation rule:

NOT(  AND(    NOT(ISBLANK({!State})),    OR(       LEN( {!State}) <> 2,       NOT(CONTAINS({!State}, UPPER({!State})))     )  ) ) 

ZIP (Postal) Code (USA)

Error message example:

ZIP code needs to be in XXXXX or in XXXXX-XXXX format.

Validation rule:

REGEX({!MailingZIP} , "\d{5}(-\d{4})?")

Revenue

Error message example:

Your entry needs to be shorter than 16 digits.

Validation rule (Currency upper limit):

{!Revenue}<10000000000000000

Email

Error message example:

Please enter a valid email address.

Validation rule:

REGEX({!Email_Address},"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}")

Phone number

Error message example:

Please enter a 10 digit phone number.

Validation rule:

AND( LEN({!Mobile_Phone})=10, NOT(REGEX({!Mobile_Phone} ,"^[a-z A-Z]*$"))) 
 

Incorporating Salesforce Flow validation rules into your automated workflows can be transformative for maintaining data accuracy and enforcing business standards. These rules not only ensure that critical data points like names, social security numbers, and contact information meet required formats but also prevent incomplete or invalid entries from progressing through your system. By using validation rules to define acceptable data criteria, you create a more reliable, error-resistant environment that supports both user confidence and data integrity. 

Explore related content:

6 Things You Can Do With The Transform Element

Top 9 Salesforce Winter 25 Flow Features

Enhance UX in Flow with Custom LWC Icon Selector