Last Updated on February 10, 2022 by Rakesh Gupta
Salesforce Flow allows us to automate business processes by building applications, known as Flows. Using Flows, a user can collect information; or, they can update, edit, or create records in Salesforce. Furthermore, Flows can execute logic, interact with the Salesforce database, call Apex classes, Platform Events, and guide users through various screens to streamline the process of collecting and updating data. Once a Flow is built, an Admin can make the Flow available to the right users or systems.
Salesforce Flow is similar to the Visualforce page for admin – for, by using Salesforce Flow, an Admin one can create a powerful wizard for data entry or display a message without writing a single line of code!
There may be times when an Admin wishes that s/he could add a Lookup field to Flow Screen Element. Now Salesforce Flow does support the Lookup field. Otherwise, an Admin needs to use a Lookup field, s/he has to use Dynamic Record Choice.
For example, suppose you want to use lookup functionality to display Chatter Group – based on matching results – to users based on their input. If so then, you can do so using the following Elements:
- Two Screen elements
- One Textbox field
- One Dropdown List field
- One Variable
- Dynamic Record Choice
Check out this video for detailed instructions:
Screenshot for your reference (transcript of the video):
Ya, I know! Looks, and is, pretty complex to build a Lookup kind of field in Salesforce Flow.
You may be wondering – can I achieve the aforementioned solution using just one field with a better outcome?
Well, you are in luck! Let’s see how
Business Use Case
Edward Backhouse is working as a System administrator at GurukulOnCloud. He received a requirement to add a Lookup field on the Flow Screen element which should instantaneously display Account based on user input.
The solution for the above business requirement
There are a few possible solutions for the above business scenario. One of them, of course, is to continue to use the old method, as shown in the preceding screenshot.
But, Edward is a Salesforce Ninja-like us! And, therefore, he is always on the lookout for creative options. As a result, Edward found that a lookup Lightning Component offered by the Flow team! So, instead of using the old method, he took the following steps:
- Navigated to Setup (Gear Icon) | Setup | Process Automation | Flows in Lightning Experience.
- Select Screen Flow in the option and click on the Create.
- Next, he used the Screen element to display the Lookup field. Edward clicked on the Elements tab and dragged and dropped the Screen element onto the canvas. This opens a new window.
- On the Screen element, Edward navigated to the Screen Components tab and double-clicked on the Lookup field to add it on to the Screen element – as shown in the following screenshot:
- On the Screen overlays preview pane, Edward clicked on the [Lightning Component] field to configure its settings, as shown in the following screenshot:
- Edward knows that he can pass values between the flow and the component by using the component properties. As a result, in the end, Edward’s Flow component looked like the following screenshot:
- The attributes Edward used in the above components are as follows:
- Object API Name – Enter the object API name
- Field API Name – Enter the field API Name that will show up in the list box to represent a record.
- Label – Enter a label that appears next to the lookup control
- In the end, Edward’s Flow will look like the following screenshot:
- Edwards, Saved the Flow with name Lookup Example – Flow and close the canvas.
- Follow Edward’s footsteps – don’t forget to activate the Flow by clicking on the Activate button!
It’s time to test this feature
Now users can use the Lookup field instead of any other workaround.
If you have any problem with watching the video then, please click on it and open it in another tab. I hope you can learn from the blog about how to use the Lookup field in the Flow Screen element!! Yes, go ahead! Show off your newly acquired skills to your friends, colleagues, and families!
Please feel free to add constructive comments, insights – and yes, challenges too! – to the blog. Good Luck in your Journey towards becoming a Salesforce Ninja!
Why did we use OBject Api name to be contact. I am still new with Flows so i am very confused. If we think about a different scenario where can we lookup to Opportunity or custom object?
Hi Rakesh, would you be able to take one step further, and show how the user can lookup a contact, hopefully filtered from the account chosen in above?
Unfortunately out of the box Lookup doesn’t support it. Take a look at the custom Lookup component here in Unofficial SF.
Hi Rakesh, Thanks for the detailed solution which i was looking for. Is it possible to pre populate the Lookup field value from the object selected with the lightning component? can you help here? Thanks!
I think – Yes, it is possible. Use “Default Value” attribute of Flow component.
Hi Rakesh, thank you for the solution. I am trying to install this Lightning Component in sandbox but every it is prompting to enter PROD login details. Could you please help? Thanks in advance!
Make sure to change installation URL to test