Ads

Thursday 22 August 2013

ISBLANK() or ISNULL() in Salesforce?

To determine if an expression has a value or not, you can use ISBLANK() function in Salesforce. It will  returns TRUE if it does not and if it contains a value, this function returns FALSE. You can use this function in formula field, as well as in workflow.

ISBLANK(expression) and replace expression with the expression you want evaluated.
sample:
IF(ISBLANK(Maint_Amount__c), 0, 1)

A field is not empty if it contains a character, blank space, or zero. For example, a field that contains a space inserted with the spacebar is not empty.

If you use this function with a numeric field, the function only returns the specified string if the field does not have a value and is not configured to treat blank fields as zeroes.

You also can use BLANKVALUE() function to determine if an expression has a value and returns a substitute expression if it does not. If the expression has a value, returns the value of the expression.
sample:
BLANKVALUE(Payment_Due_Date__c, StartDate +5)
Use the same data type for both the expression and substitute_expression.

How about ISNULL() ?
Use ISBLANK instead of ISNULL in new formulas. ISBLANK has the same functionality as ISNULL, but also supports text fields. Salesforce will continue to support ISNULL, so you do not need to change any existing formulas.

The same goes for NULLVALUE(), it is similar with BLANKVALUE(), with exception:

Avoid using NULLVALUE with text fields because they are never null even when they are blank. Instead, use the BLANKVALUE function to determine if a text field is blank.
Don’t use NULLVALUE for date/time fields.

Choose Treat blank fields as blanks for your formula when referencing a number, percent, or currency field. Choosing Treat blank fields as zeroes gives blank fields the value of zero so none of them will be null.

No comments:

Post a Comment