How to use a Record Lookup

For this post we are going to show you something that really sets Flow apart from Process Builder.  We are going to ignore showing you a standard Record Lookup based on an Id, and instead get into something ever so slightly more complicated.  But, this should help you to be creative in your Flow designing.  You have to ‘lookup’ your data somehow.  If you didn’t need to do a Record Lookup/Fast Lookup you most likely could just use Process Builder.  Just as I said for on Record Update post, if you have not yet read the Record Create post, go read that for some tips and tricks that will be skipped in this post.

Our business case for this example is that we want to find the LAST WON Opportunity Amount, so that we can place it into a field on the Account to be referenced in List Views and Reports.

Where is the Record Lookup element?  You can find the Record Lookup element under the DATA section of the Palette.

Find Record Lookup

Just like in the Record Create, we need to choose the Object that we are going to make an Update on.  Make sure you type the name instead of scrolling down!

Select the Object

Now that we have selected the Opportunity Object, we need to set our filter criteria.  Just like other elements, we have the ability to add additional rows to the filter by selecting “Add Rows”.  In this case, we are going to use this so that we can filter out all of our Opportunities that are not Won yet.  Notice, we are using the field “IsWon” instead of Stage.  This will allow us to make sure any changes to the Stage values do not affect this filter.  I used the SYSTEM field “{!$GlobalConstant.True} instead of creating my own value, use what Salesforce has given you to save some time!

Setting up the Filters p1

Great, so we have our filters set.  However, what if we have multiple Won Opportunities?  I know a Record Lookup only will return me one record, but how can I make sure its the most recent?  Well, thanks to the good people at Salesforce they gave us the ability to sort our results!  So, that means we can set sort on the Close Date so that the most recent Close Date gets selected.

Sort the Results

Congrats, you have successfully filtered your Opportunities to grab the most recent Won Opportunity.  Now, lets grab the Amount from the Opportunity so that we can reference it later in our Flow on a Record Update.  Remember, make sure your variable matches the type of field that you are pulling from (Currency in this case).  Note, you have the option to assign null values if no records are found by checking the checkbox near the bottom of your Record Lookup.

Assigning variables

RECAP:  Record Lookup elements let you search for any record in Salesforce.  In the situations where you are dealing with many possible records, such as the above example, you will want to use more than one filter and possibly even sorting your results to get the correct record.  Remember, you can grab as many fields as you need to from the record you are looking up.

One thought on “How to use a Record Lookup

Leave a Reply

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

You are commenting using your 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 )

Connecting to %s