(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.
- 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.
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.
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.”
This is the end product:
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.
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.
- 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.