Search Component - lookup field

  • 1
  • Question
  • Updated 1 year ago
  • Answered
I added a lookup relationship field to the template of the search component but it doesn't seem to be searching the lookup field values. Is this not possible?

For example: Using only the Contact object in the search I want to also search for Accounts. I add the Account field from the contact record but no results appear when searching for an account name.
Photo of Tami Lust

Tami Lust

  • 5,280 Points 5k badge 2x thumb

Posted 1 year ago

  • 1
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
The relationship field I think is a reference to the record Id, not the name, so you would have to use the account name field instead of the reference field.
Photo of Tami Lust

Tami Lust

  • 5,280 Points 5k badge 2x thumb
Hi Raymond,

I am using Account__r.Name and the name shows in the template. If I just search by the Account name it doesn't yield any results.
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
I can't explain why it is happening but a quick work around would be to add a salesforce formula file on the contacts object that returns the account name, the add that field to your search
Photo of Tami Lust

Tami Lust

  • 5,280 Points 5k badge 2x thumb
Hey Raymond,

I thought that would work also but it doesn't. If I search for the Account name through the Contact object it returns no results.
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 11,050 Points 10k badge 2x thumb
Hi Tami, the search component would need to have a return object set up for each of the objects that you'd like to search through. Is there something specific to your use case that prevents you from adding Account as a return object?
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
Depending on use case, you may only need one return object. For example, if yo wanted all the records from all the objects related to contacts to filter by a specific contact, then you could have contacts be the return object and the set the conditions on each model equal to the contact Id. Then you could filter multiple models/objects by the record Id from a single return object..