RSS

Test For Presence of ID in Visual Flow

13 Nov
Test For Presence of ID in Visual Flow

Here is a quick question: What is the best way to test for the presence of an Id? For example, if you have a flow that may or may not receive an Id from the calling source, how do you know if you received on or not? Or, how do you know if the ParentId on an Account record (or AccountId on a Contact or Opportunity record) is populated or not?

The first thought that comes to mind is to see if the Id is an empty string:

Compare To Empty String

Compare To Empty String

Unfortunately this solution doesn’t always give you consistent results.  Grrr. 😦


So here’s a quickie tip:

Create a function that returns the length of the string, then check to see if the length is greater than zero:

Length Formula

Length Formula

Compare String Length to Zero

Compare String Length to Zero

Cheers!

Advertisements
 
1 Comment

Posted by on November 13, 2015 in Formulas, Visual Flow

 

Tags: , , ,

One response to “Test For Presence of ID in Visual Flow

  1. atjohnson9

    July 7, 2016 at 6:28 pm

    great idea! I too have found the empty string approach to be less than reliable. One of my tricks is to check the first three of the returned variable for the objects prefix, but I think I like yours better!

    This would be a good one to create a small flow in your org that just does ID checks, then you can keep using the functionality without recreating the wheel ever time.

    Like

     

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: