Best Way To Merge Validation Rules And Flows In Salesforce

Best Way To Merge Validation Rules And Flows In Salesforce

Best Way To Merge Validation Rules And Flows In Salesforce

Introduction

Have you ever had the experience of merging your validation rule and flow into one big data set? You may have wondered if there was the best way to do this. 

Salesforce can help you automate the validation of these data and fields. This blog will discuss the best way to implement validation rules and flow in Salesforce. 

The first step is to create a validation rule that checks whether the entered values are valid before saving the record. This will allow you to take action if there is an invalid value or if there is no value at all. 

For example, Suppose you want to ensure a user has entered their phone number as a valid one before saving it as a contact record. In that case, you can create a validation rule that checks whether their phone number is less than ten digits and does not include space between numbers or dashes.

The validation rule checks whether data entered by a user meets the criteria you specify before it can be saved. 

A validation rule contains an expression that evaluates the data in one or more fields and returns a boolean value of “True” or “False.” 

A user receives an error message if the criteria are met, 

which means that the rule returns “True”.

You can create a validation rule for the object by navigating to it in the Object Manager, clicking on Validation Rules, and creating one for the object. 

The interface is simple and lets you choose fields from the current or parent records. 

You can also select fields from a parent record or a record that is related to the master-detail field.

You cannot select a field from a child record or a record that is not directly related to the current record. 

Best Way To Merge Validation Rules And Flows In Salesforce☁️☁️.

Let’s create a record-triggered flow that runs when the Date Of Birth Field Is Blank. Then display an error Pop-Up message if it Date Of Birth is blank.

Before Creating The Record-Triggered Flow:

Step 1: Create a Picklist Field In The Account Object In Salesforce

 

  • Click Object Manager     
  • In the Quick Find Search box, enter Account. 
    • Click on, Field & Relationships Tab,
    • Click On the New Button,
    • In The Data Type, Select Checkbox Data Type, 
    • Click on Next Button.

  • Enter a Field Label: Validation Rule Field then Field Name will auto-populate (Validation_Rule_Field).
    • Default Value: Unchecked.
    • Click on Next Button.
    • Click on Next Button.

    • Click on Save Button.

Step 2: Create a Validation Rule In Account Object In Salesforce

 

  • Click on, Validation Rules Tab,
    • Click on, New Button
    • Enter a Rule Name: Validation_Rule_For_DOB_Field
    • Active: True

    • Error Condition Formula: Validation_Rule_Field__c (Checkbox Field)
    • Click on, Insert Field,
    • Then Click on, Account,
    • Then Click on, Validation Rule Field (Checkbox Field)
    • Then Click on, Insert Button.

  • Error Message:
    • Error Message: Date Of Birth Field Is Empty, So You Can’t Save This Record
    • Error Location: Field: Date Of Birth Rule (Date Field) 
    • Click on, Save Button

Step 3: A] Salesforce Flow – Create And Specify Flow Properties

 

We must use the Before Save flow

Follow the directions below:

  • Click Setup.
  • In the Quick Find search box, enter Flows.
  • Select Flows, then click on New Flows.
  • Select the ‘Record-Triggered Flow’ option and click ‘Next’ 
    • Select Object: Account
    • Configure Trigger: Trigger The Flow When (A record is created)

 

  • Set Entry Conditions
    1. Conditions Requirements: None
  • Optimize the Flow For Fast Field Updates 
  • Click Done.

Step 3: B] Salesforce Flow – Add Decision Element From The Toolbox

 

Let’s now add the Decision element to check the Date Of Birth Field is Empty.

Follow the directions below:

  1. From the Toolbox, select the Decision Element
  2. Enter a name in the Label field (Date Of Birth Field Is Empty?); then API Name will auto-populate (Date_Of_Birth_Field_Is_Empty).
  3. Under Outcome Details, enter the Label (Yes ) then API Name will auto-populate (Yes).
  4. Condition Requirements to Execute Outcome: All Conditions Are Met (AND)
    1. Resource: {!$Record.Date_Of_Birth__c}
    2. Operator: Is Null 
    3. Value: {!$GlobalConstant.True}
  5. Click Done.

Step 2: D] Salesforce Flow – Adding an Update Records Element

 

The next step is to update the Validation Rule Field (Checkbox) to True. We will use Update Records Element

Follow the directions below:

  • From the Toolbox, select Update Records Element. Drag and drop Update Records onto the canvas. 
  • Input the following information:
    • Enter Label Field (Validation Rule Field To True) then API Name will auto-populate (Validation_Rule_Field_To_True).
    • How to Set the Record Fields: Use the account record that triggered the flow
    • Set Filter Conditions: None-Always Update Record
    • Set Field Values for the Account Record: 
      • Field: Validation_Rule_Field__c
      • Value: True
  • Click Done.

In the end, Flow will look like the following below screenshot:

  1. Click Save.
  2. Enter the Flow Label Field (Date Of Birth Field Is Empty) the API Name will auto-populate (Date_Of_Birth_Field_Is_Empty).
  3. Click Save.
  4. Click Activate.

Final Proof Of Concept (Output)
  • Navigate to Setup | Select App Launcher | Select Sales App
  • Click on, the Accounts Tab
  • Click on, New Button

You can follow these basic steps to ensure success when creating the account record,

 If the Date Of Birth Field Is Empty then Display Validation Rule Error PopUp Message,

In Salesforce create an Account Record if the Date Of Birth Field is empty, 

then you will verify whether or not it Record has been saved.

Conclusion

We explored the best technique to build validation rules and flow in Salesforce in this article. First, we created a picklist field in the account object in Salesforce, then we created a validation rule in the account object to determine whether the value is valid or not, then we created a salesforce flow, then we added decision elements from the toolbox to it, and finally, we saw the final proof of concept. We hope you found this useful.

Summary
Article Name
Best Way To Merge Validation Rules And Flows In Salesforce
Description
To merge your rule and validation flow into a sizable data set. This blog has highlighted your best choice for automating the validation of these data and fields in Salesforce.
Author
Publisher Name
BugendaiTech Pvt Ltd
Publisher Logo
Spread the updates

Leave a reply



Notice: Undefined index: position_on_screen in /home/tl2jq5v7asif/public_html/wp-content/plugins/mystickyelements/mystickyelements-front.php on line 203