Lookup Screen Component in Salesforce Lightning Flow
Lookup Screen Component in Salesforce Lightning Flow: Salesforce has released a new screen component – Lookup. As the name suggests, this new screen component lets users search for a record in a flow just like a lookup field in Salesforce.
Before this, the only option to select a record in the flow was to use the picklist screen component and each picklist value will denote a separate record of an object.
Using the lookup screen component users can easily search and define the record in the flow and you can also set the current recordID or default value in the lookup field in the flow so that users don’t have to select the record every time they are running the flow from a record.
How to Use the Lookup Screen Component in Salesforce Lightning Flow?
Let’s consider a use case where you need to create a screen flow and want to get some input from the users. And once the flow is executed you want to create a record from the user’s inputs and get it related to a parent object.
In my case, I have a survey object which has a lookup relationship with the account. On the account page, I want the users to go through a set of screens and then the flow will create a Survey record and show as a related list on the account page once the flow is executed. For that, we need to link the survey record to the account record by mentioning a value on the lookup field in the flow.
In the above screenshot, I have added a lookup field by the name of Account since I want to display the account records in my lookup field.
Field API name – Enter the API name of the field which is a lookup field to the object of which you want to show the records. In my survey object, I have a field by the API name AccountName__c which is a lookup to accounts.
Label – Field label of the lookup field which appears on the flow screen.
Object API name – The API name of the source object. The object where the field API name is present.
Record id – Record ID value for the lookup. You can mention the current record id so that by default the lookup field shows the current record from which the flow is executed.
Require – Requires users to enter a value before they can move to the next screen.
Store lookup values in the flow
When you add a screen component to flow, the values are automatically stored in a variable. When the user navigates to the next screen, the values are assigned to the flow variable.
To store values manually, select manually assign variables (advanced).
All attributes are available to store inflow variables, but most likely you must store this attribute.
ATTRIBUTE | DESCRIPTION |
Record ID | The ID of the record that the user selects. You can store this value in a text variable. |
Record Name | The name of the record that the user selects. You can store this value in a text variable. |
7 comments
Skip to comment form
One issue I encountered which will not allow to switch to a standard lookup component:
Create a lookup on Account which will search for Accounts with given filter:
Source.Market equals Lookup.Market
If this flow is included on Account record, the source record market will always be null, therefore it will always return values where Market is not set, although it works when specific value is provided.
There is no alternative since we cannot pass any query condition to lookup component and we only depend on lookup field filters.
How to make lookup field mandatory
I am encountering an issue in which the lookup field works flawlessly on desktop but breaks on mobile. Is there a workaround for that? Thanks!
Are you using the variable recordId or Id for mobile?
The mobile version uses Id. So what you can do is add both variables as available for input. And check whether or not Id is empty. If it’s not then you are using the mobile version.
A good solution would be to assign Id to recordId if Id is not null or just use a third variable or something
I have tried the same thing in the lookup component to populate the current record, but its not showing up. What I might be doing wrong?
I want to create a new record from Lookup Component inside the flow. “+ New Account” is not showing in flow lookup component. Any alternate ideas would be helpful please.
Setting a lookup field on the screen flow to Required = True seems to have no effect. Is this a bug?