How to Create Lookup field in a Salesforce Flow

In Salesforce, Flows allows us to connect and manage data for different standard and custom objects with automation. The Lookup fields allow us to establish relationships between records, simplifying workflows and more efficient data management within the Salesforce environment.

In this Salesforce tutorial, we will learn to Create a Lookup field in Salesforce Flow.

Create Lookup field in a Salesforce Flow

To use a Lookup field in a Salesforce Flow, we will create a Screen flow and, for that, navigate to the Setup of the Salesforce and follow the below steps.

In this Screen flow, we will create a Contact from the home page through Screen flow and link it with an Account. In the Lookup field of the screen flow, we will give options to the user to select the account for the Contact record.

1. On the Setup page of Salesforce, go to the Quick Find box and search, then select Flows.

How to Use Lookup field in a Salesforce flow

2. In the Flows setup, click on the New Flow button.

3. Select the option Screen flow and click Create.

How to create Lookup field in a Salesforce Flow

4. Add the Screen element to the flow.

Use Lookup field in a Salesforce flow

5. In this screen, we take input for contact records, so I have entered the Label as Contact details and the API Name will be auto-filled according to the entered label.

Now, add the text component to the screen region. The text field will take input from the user.

Creating Lookup Field in Salesforce Flow

6. Enter the Label and API Name for the text component. Here, I have added two text components, First Name, and Last Name, to take details for creating a Contact record.

Populate Lookup Field on Flow in Salesforce

7. Now add a Lookup field to the screen region and enter the below fields.

  • API Name – Enter API Name for the lookup.
  • Field API Name —This screen flow creates a contact record, and the contact is a child of the Account, so enter the Field API Name as the AccountId.
  • Label —In the Contact record, the Label for the AccountId is Account Name, so we have entered the same. You can check this label and API Name in the object manager.
  • Object API Name – Name of the source object for which you are creating the record. In this case, it is Contact.
  • At last, click on the Done button.
Choose a Lookup Option for a Flow Screen in Salesforce

8. After this, add a Create Record element to the flow.

Use Lookup field in a Salesforce Screen flow

9. Enter Label and the API Name for the Creat Record element. After this, activate the radio button ‘Use Separate values and literal values, ‘ then select Contact in the Object field.

Creating Lookup Field in Salesforce Flow builder

10. In the section Set Field Values for the Contact, we need to map the contact fields with the variables of screen flow.

See also  How to Create Platform Event-Triggered Flow in Salesforce

Map the fields First Name and Last Name with the values first name and last name, then add a filed AccountId and map it with the value Contacts_accounts > Record Id.

Here, Contacts_accounts is the API name of the lookup field.

Roll-up summary field in Salesforce flow

11. Save the flow by entering the Flow Label and Flow API Name.

Use Lookup Field into a Salesforce Flow Screen Element

12. Activate the flow by clicking the Activate button.

Add Lookup field in a Salesforce flow

After activation, the flow can be used to add to the record or home page.

Add the screen flow to the home page

To add the created screen flow on the home page, navigate to the home page of the application where you want to deploy this screen flow and follow the steps below.

1. On the Home page, click on the settings icon, and from the options in the dropdown, select Edit Page.

2. As we click on the edit page, the home will open in the lightning app builder. Here, drag and drop the Flow component to the template region.

How to Add Lookup field in a Salesforce flow

3. On the left side of the window, select the created screen flow in the Flow field, and after that, click on the Save button to apply button.

Configure a Lookup Field in Salesforce flow

4. Go back to the home page and enter the contact details to create the contact record, and as we click on the lookup field in the flow, the available account records will be visible in the lookup field.

How to Configure a Lookup Field in Salesforce flow

After this, click Next to create contact.

In this way, we can Create or use a Lookup field in a Salesforce flow by following the above steps.

See also  How to Add Validation to Screen Flow in Salesforce

Conclusion

In Salesforce, Lookups are helpful for establishing relationships between records and objects, that enhance automation and data management within Salesforce. By following the above steps, you might have understood, how you can create a lookup field and use it in your Salesforce flow.

You may like to read: