Salesforce ISNUMBER Function

In this Salesforce tutorial, we will learn about the Salesforce ISNUMBER function with its use cases, syntax, and practical examples. The ISNUMBER function is executable in the formulas and validation rules of Salesforce Lightning and Salesforce Classic.

What is ISNUMBER Function in Salesforce

In Salesforce, the ISNUMBER function is a formula function that is used to determine whether a given expression or field contains a numeric value. This function returns a Boolean value true and false, based on whether the specific value is a number.

This function is executable in various scenarios like when you have to identify whether a field contains a numeric value or not, then you can use this function to create a validation rule.

Syntax for ISNUMBER function in Salesforce

The basic syntax of the ISNUMBER function is as follows:

ISNUMBER(expression)

The expression in the above syntax is the value or field that you want to check for being a number.

Considerations:

There are a few considerations that we should be aware of while using the ISNUMBER function for formula fields and validation rules.

  • If the field value is left blank then the function returns FALSE.
  • The field input including languages and special characters including a space returns False.
  • The ISNUMBER function returns TRUE for scientific formatting such as “3BD”.

Use the ISNUMBER function in Salesforce Lightning

In this example, we will create a validation rule in the Opportunites object using the ISNUMBER function. This validation rule will ensure that the custom field Tracking Number only contains a numeric value and only takes input like 12060 instead of 120UID.

This validation rule will give an error if the field is entered with any values other than numerical.

Now follow the below steps, to create a Validation rule in Salesforce Lightning.

1. Navigate to the Setup page of Salesforce Lightning and for that click on the Settings icon and in the dropdown select the Setup option.

2. In the Setup window of Lightning, click on the Object Manager tab.

3. From the list of objects in the Object Manager select the Opportunities object.

4. In the setup of the Opportunity object, go to the left sidebar and select Validation Rules then in the next window click on the New button.

Salesforce Lightning ISNUMBER function

5. In the field Rule Name enter a relevant name for the validation rule. In this example, I have labeled the validation rule as Tracking Number Validation.

Define a Validation rule using ISNUMBER function in Salesforce

6. In the section Error Condition Formula, enter the below formula in the formula editor.

AND(
  NOT(ISBLANK( TrackingNumber__c )),
  NOT(ISNUMBER( TrackingNumber__c ))
)
  • The AND function returns true only if all specified conditions in the formula are true.
  • NOT(ISBLANK( TrackingNumber__c )), checks if the “TrackingNumber__c” field is not blank.
  • NOT(ISNUMBER( TrackingNumber__c )), ensures that the value in the “TrackingNumber__c” field is a numeric value.

7. After entering the formula, click on the button Check Syntax to check the error in the formula.