Checks whether an expression results in an error or null value in Salesforce Spiff and either returns the result of the expression or returns a default value for error handling. This function provides an alternative nested if() statements, but this function can also disguise real errors and result in inaccurate calculations if not used carefully.
Required Editions
Available in: both Salesforce Classic (not available in all orgs) and Lightning
Experience
Available in: Enterprise, Unlimited, and Developer
Editions
Available for an additional cost in: Professional Edition with Web
Services API Enabled
Syntax
iferror(expression, error_expression)
Arguments
Argument
Required?
Description
expression
Required
The condition to test.
error_expression
Required
The error handling to execute when the expression results in an error or null value.
Considerations
Important Don't use this function if you can't diagnose the source of an error.
This function doesn't discriminate which errors to handle. For example, maybe you're trying to prevent a divide-by-zero error for this formula.
if(DenominatorField = 0, 0, DivisionCalculation)
When you use iferror(DivisionCalculation, 0), an error can occur in the numerator, denominator, or any part of the calculation. Each error returns 0 with no error message.
The iferror() function also breaks the trace. If the if(DenominatorField = 0, 0, DivisionCalculation) expression includes ARR divided by quota, attainment appears as 0 on the statement and ARR and quota appears as 0 or not a number for the record. When you specify a divide-by-zero check, you see the values for ARR and quota if they exist.
Example
A rep has a custom rate assigned by a quota table, and you want to check whether the rate for a rep is empty. If so, prompt the admin to specify a rate for the rep. For the expression to test, calculate the rep's rate. For the error_expression argument, use the error() function to show a message for resolving the error condition.
Tip The iferror() function is helpful when you're creating calculations and want to test for missing logic or variables. To prevent errors in production logic, use the iferror() function only during development and testing.
We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required Cookies
Always Active
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional Cookies
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising Cookies
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.