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.

 

20 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

  3. Hey Jenwlee,
    Your blog posts are super helpful, thank you for all your work.

    I’m encountering a problem where I want to look up a record for an object via a screen flow on the home page but because I’m giving the User the ability to choose which object they want to look through and then search through all records in that object, I can’t figure out how to get the lookup ID in the Field API Name. (This is supposed to be designed as a simplified way to document activities via the new mobile app while on the road).

    Suggestions?

    Like

  4. You are trying to lookup objects using the lookup component? I don’t think there is any lookup field that points to object. You would need to build a custom lightning component that looks up objects. You can’t currently do a Get Records that is generic, not object specific. That is a feature coming in Spring 20, which requires code. Otherwise, you would need to invoke Apex to do a query based on the selected object. If you need to build this now, I would recommend you build a lightning component to do everything. It isn’t doable with flow without code.

    Like

  5. Thanks for the quick reply and I’ll look into creating a lightning component if I have to.

    Even so, some help on unravelling the error code would be a help too if you can. I have the User choose the object through a choice set (Lead, Account, Contact, Opportunity) and then use that as the variable in the lookup component on the next screen.

    My issue is that I keep getting the following error when trying to lookup a contact:
    API Error Code:INVALID_CROSS_REFERENCE_KEY. Error Message:Unable to parse constraint: USING LOOKUP Account.MyContactID__c BIND Id = ‘undefined’ ^ ERROR at Row:1:Column:58 Invalid id: ‘undefined’. A valid id must be used when using bind on the id field..

    Also, I’m still puzzling through that as well as how to get a reference to a Lead ID through something else. (The WhoID via Task is unsupported, according to another error code).

    I don’t know if this triggers any other hints or suggestions, but if not, I appreciate your help and I’ll get on the lightning component in the morning.

    Like

  6. Please reach out to me on the Trailblazer community so you can attach screenshots. This is not a good forum for troubleshooting. I need to see how you are configuring this to help guide.

    Like

  7. Hey Jenwlee,
    I am creating a screen flow using Lookup Component, and there are 2 fields, Manager 1 and Manager 2, using the same Lookup API Name, User. When I created the second Lookup Component for the Manager 2 field, the system error message is “This API name is already used for another element or resource in the flow.”
    Is there a way to solve this?
    Thank You.

    Like

  8. The API name (of the lookup component) has to be unique, but you can use the same lookup field, user. For example, I can use the owner lookup field on the account twice. Specify the field API name: Owner and the Object API name: Account

    Like

  9. Thanks for the quick reply Jenwlee!
    But I also has another field which is using the Lookup Component from API Name Account.

    Like

  10. Manager 1 and Manager 2 are custom fields in Account Object, both of them are a Lookup field to the User Object. I am creating a Screen Flow to populate these 2 fields so that the user can update the fields if needed by using the Lookup Component.
    Another questions is, when I populate the Checkbox field on the Screen Flow, it shows a “true” words instead of a checkbox format, how to convert it to display the checkbox?

    Thanks!

    Like

  11. Yes, I understand that. This is how you configure the lookup components. Manager 1: (API Name is Manager1, Field API Name Owner, Object API Name: Account), Manager 2 (API Name is Manager2, Field API Name is Owner, Object API Name: Account). True = checked. False = unchecked. A checkbox is a boolean and the underlying values are true or false.

    Like

  12. I’m trying to make a lookup to the case object, but I’m getting this error:
    “Looks like you don’t have access to this field, or the object or field API name is not valid on this Lookup”
    I’m trying to reference the parent case field on the case object? Can I not do that?

    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