Salesforce ISBLANK Function

In this Salesforce tutorial, we will learn to use the ISBLANK function in Salesforce CRM. We will discuss the use case of the ISBLANK function with the help of a validation rule. This function is executable in Salesforce Lightning and Classic editions.

What is ISBLANK function in Salesforce

In Salesforce, the ISBLANK function is a formula function used to check if a specified field or expression is empty or null. It returns a Boolean value (true or false) based on whether the specified field or expression contains data.

It can be used in the fields, reports, workflow rules, and validation rules. While using this function in a validation rule an error message will trigger if the field is left blank.

This function is particularly useful for data validation and conditional logic within the Salesforce platform.

Syntax of the ISBLANK function

In Salesforce ISBLANK function is executed with the help of the syntax below.

ISBLANK(expression)

In the above syntax, the expression is supposed to be replaced by a field, field reference, formula, or any valid expression. The function evaluates whether the specified expression is blank or null. If the expression is blank or null, the function returns TRUE otherwise, it returns false.

Considerations:

There are a few considerations that we should be aware of while using the ISBLANK function in Salesforce.

  • If you want to check the null values then use the ISNULL function instead of the ISBLANK function because The ISBLANK function returns True for both null values and empty strings.
  • The ISBLANK function is often used in validation rules to ensure that certain fields are not left empty when records are created or updated.

How to use ISBLANK function in Salesforce Lightning

In the below steps, I will explain the execution of the ISBLANK function in Salesforce Lightning with the help of a Validation in Salesforce object.

1. Navigate to the Setup page of Salesforce Lighting, and for that click on the settings icon that is on the upper right of the screen.

2. On the Setup page of Lightning click on the Object Manager tab.

3. In the Object Manager, select an object to set a validation rule using the ISBLANK function. In this example, I have selected the object Account.

4. In the setup window, click on Validation Rules in the left sidebar and then click on the New button.

Use Isblank function in Salesforce

5. In this step, we will define the validation rule with the help of the ISBLANK function.

  • Enter a relevant name for the validation rule in the Rule Name field. In this example, I have named the validation rule as Account Validation.
  • Go to the Functions scroll bar and select the function ISBLANK then click on the button Insert Selected Function.
Salesforce Lightning IsBlank function use case

6. After inserting the ISBLANK function in the formula editor we need to replace the expression in the function with a field. To select a field click on the button Insert Field.

Insert field in IsBlank function in Salesforce

7. In this window, select a field to add it as an expression to the ISBLANK function in the formula. After selecting the field click on the Insert button.

In this formula, I have used the field Shipping Address as an expression in the function.

Create a Validation rule with ISBLANK in Salesforce

8. After adding an expression in the function, enter the Error Message field. The message entered in the text area of the error field will appear when the Error Condition formula is true.

Click on the Save button after entering the error message.

ISBLANK function in Salesforce Lightning

Now open the object in which you have created this validation rule and when you will edit or create a record while leaving the field blank that is used in the formula of the ISBLANK function, you will get an error message on the screen.

ISBLANK function error message in Salesforce Lightning

As we see in the above image, on leaving the field blank that we have used as an expression in the ISBLANK function, we got an error message on the screen because the validation rule that we have created is returning the formula as True.

In this way, we have successfully executed the ISBLANK function with the help of a Validation rule in Salesforce Lightning.

How to use ISBLANK function in Salesforce Classic

In this example, we will discuss the execution of the ISBLANK function in Salesforce Classic with the help of the Validation rule in Salesforce Lightning.

1. On the Home page of Salesforce Classic, click on the Setup tab that is on the upper right side of the screen.

Salesforce Classic ISBlANK function use case

2. In the Setup tab to the left-hand sidebar click on the Customize dropdown and select the object to create a validation rule using the ISBLANK function.

In the dropdown of the object click on the Validation rule.

Salesforce Classic create validation rule using ISBLANK

3. Now click on the New button to create a validation rule.

ISBLANK function Validation rule in Salesforce

In the next step, we will define a validation rule by specifying an error condition and a corresponding error message.

The error condition is written as a Boolean formula expression that returns true or false. When the formula expression returns true, the save will be aborted and the error message will be displayed.

4. Enter the label for the error field in the Rule Name field. In this example, I have named the error field label as Contact validation.

Go to the Functions scroll bar in the right sidebar then select ISBLANK and click on the button Insert Selected Function.

Create a Validation rule with ISBLANK in Salesforce Classic

5. After entering the ISBLANK function in the formula editor click on the button Insert Field to insert field in the expression of the function.

Insert field in IsBlank function in Salesforce Classic

6. Select a field from the list of available lists in the objects and click on the Insert button.

ISBLANK function in Salesforce Classic

7. After entering the Error condition Formula click on the button Check Syntax to validate the formula.

After successful validation, write the message in the Error Message field that will appear when the Error condition is True.

At last click on the Save button.

Salesforce Classic Insert field in IsBlank function

As we click on the Save button the validation rule will be saved in the selected object.

When we will edit or create a record in the selected object the Error will be triggered when the expression field of the function is left blank.

Now I will open the object record, in which we have created an Error condition validation rule using the ISBLANK function.

Error Condition Formula in Salesforce using ISBLANK field

As we can see in the above image the validation rule is triggered that we have created using the ISBLANK function and displaying the error message on the screen when the field is left blank.

In this way, we have successfully executed the ISBLANK function in Salesforce Classic with the help of a validation rule.

Conclusion

In this Salesforce tutorial, we have learned about the use case of the ISBLANK function in Salesforce. We successfully created a validation rule using the ISBLANK function in Salesforce Lightning and Salesforce Classic respectively.

Along with this we also discuss the syntax and considerations that we should be aware of while using the ISBLANK function in Salesforce.

You may like to read: