RSS

Doing Calculations with Number Fields in Visual Flow

06 Jun
Doing Calculations with Number Fields in Visual Flow

Number fields can be used in formulas in Visual Flow just like number variables. For example, if I have a number field on Account called “PriorDaysWithER” I can use that field in a flow function such as this one where the number of days in a date range are added to the value in that field:

Formula using number field

Formula using number field “PriorDaysWithER”


But a (not so) funny thing can happen, and that is your calculation may return nothing (literally nothing – a blank value).

Why is this?

It appears that when a number field has a blank value, when you use that field in a formula you’ll always get a blank value.

Luckily there are two solutions to solving this problem.


Solution 1

The first solution is to use a formula to test the field for a blank value. If the formula finds that the field is blank, it returns zero, otherwise it returns the value in the field.

Test field for blank value and return 0 of blank

Test field for blank value and return 0 of blank

You can now use that formula within another formula, or write one long formula such as the one below (I’ve left off the object name):

UsingFormulaWithinFormula

All-In-One Formula

IF(ISBLANK({!PriorDaysWithER__c}, 0, {!PriorDaysWithER})

+ {!CurrDOT__c} – {!CurrDOH__c} + 1


Solution 2

The other solution is in how the field is setup on the object. If the field is setup to have a default value you will not need to test for a blank value in your Flow formula.

Setting a default value on a number field

Setting a default value on a number field

One caveat with relying only on this solution, however, is that if the default value of the field ever gets deleted the formula in the Flow will then return a blank value.

Advertisements
 
Leave a comment

Posted by on June 6, 2015 in Visual Flow

 

Tags: , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: