How To

Look It Up in a Flow Screen

Lookup(Note: This blog posts only covers how you configure a lookup component for use in a screen flow and how to reference the lookup value selected by the user, and not all the steps to complete the flow.)

With Winter ’20, Salesforce introduced a standard lookup component for use in a screen flow. Now, you can add the ability to lookup a record on a flow screen, just like you do everywhere else in Salesforce*.

*Almost everywhere in Salesforce.

Here are a few things about this standard lookup function you should be aware of when configuring this for use.

  • Lookup filters on the field are ignored. However, if you do need more power (including the ability to filter), install the flow lookup component created by the community posted on the UnofficialSF Web site.
  • For the Field API Name, you must use a API name of an existing sObject and field. For example, if you want to lookup an account, you cannot specify the Account as the sObject and the field is Name. Rather, you can specify Contact as the sObject and the field as AccountId.

AccountId.GIF

  • Person Account consideration: the AccountId field on a Contact will not find person accounts! Use Case.AccountId or another lookup instead.
  • OwnerId can’t be used as a lookup – use CreatedBy if you need to look up users.

Business Use Case:  Addison Dogster is the system administrator at Universal Containers. Addison received a requirement to show a lookup in a screen flow.

Screen-Lookup-Demo.GIF

Solution: Addison recalled reading about the Lookup standard component in Flow Builder in the Winter ’20 Release Notes and is excited for the opportunity to give it a whirl.

Quick Steps:

1. Let’s create the flow. In Setup, for Classic, go to  Create | Workflows & Approvals | Flows. In Lightning Experience, it is found under Process Automation | Flows.

A. Draw the Screen flow element to the canvas.

B. Drag the Lookup standard component to the screen area and configure it accordingly.

  • API Name: <API Name for the screen component. This needs to be an unique name within your flow> – In this example, we called it “Account”
  • Field API Name: <Lookup field API name> – In this example, we are using the “AccountId” field. Note: If you reference a custom lookup field, don’t forget to include “__c.”
  • Label: <What you want shown as text for your lookup field> – In this example, we use “Account associated to the case.”
  • Object API Name: <Object API name that the field is associated to> – In this example, we are using the Case object. Note: If you reference a custom lookup field, don’t forget to include “__c.” 

Screen-Lookup.GIF

View Image Full Screen

This is the end product:

Screen-Lookup-Debug.GIF

View Image Full Screen

Now, if you need to reference the selection in your flow, under Screen Components, find the API name of your lookup component and select the field that you would like shown. In this case, we looked up Account > recordName to show the Account Name.

Screen-Lookup-DisplayResults.GIF

View Image in Full Screen

That’s how to configure the Lookup picklist on a screen flow and how you reference the user’s selection later in your flow.

That’s all folks.

Deployment Notes/Tips:

  • The flow can be deployed to Production in a change set (or can be deployed using a tool such as Metazao’s Snapshot).
  • You will find the flow in a change set under the Flow Definition component type.
  • Activate the flow post deployment as they deploy inactive in Production, unless with Winter ’19, you have opted in on the Process Automation Settings screen, to “Deploy processes and flows as active.” NOTE: With this change, in order to successfully deploy a process or flow, your org’s Apex tests must launch at least 75% of the total number of active processes and active autolaunched flows in your org.

 

8 thoughts on “Look It Up in a Flow Screen

  1. I’m getting the error OwnerId is not a valid lookup field. Can you not use this to specify a user for the owner of an opportunity?

    Like

  2. You need to reference the field api name and the object api name, not reference variables. So if you are using the Created By Id field- let’s pretend the field api name is CreatedById. That’s what you would put into that field. If you are using it from the Lead object, then you would put Lead in the object api name field, just like the example I used in the blog post.

    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 )

Google photo

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