Loading...

Salesforce provides many standard components that can be used in Lightning Experience to develop an application. But sometimes, we need to create custom components to meet specific requirements.

A lookup field is a reference to another object in Salesforce. It allows you to link one object to another object.

Creating a custom lookup in an Aura component allows users to search for records of a specified object type and select a record from the results.

This can be a useful feature in many applications, as it provides a quick and efficient way for users to find and reference relevant records. By default, Salesforce provides the Lookup component, but it has some limitations, such as it only works with standard objects and only allows you to search by record name.

To overcome these limitations, we can create a custom lookup component that allows us to search and link any object in Salesforce.

In this article, we will discuss how to create a custom lookup in Aura Component. Let’s begin!

Step 1: Create the Apex Class:

The first step in creating a custom lookup is to create an Apex class that will be used to perform the search for records. In this example, we will create an Apex class called ‘customLookup’ that contains a single method called ‘searchRecords’.

This method takes two parameters: the name of the object to search for and the search string entered by the user.

The method returns a list of records that match the search criteria.

Here is an example of what the Apex Class might look like

Step 2: Create the Aura Component:

Now that we have created the Apex class, we can move on to creating the Aura component that will use it. In this example, we will create an Aura component called ‘customLookupComponent’.

The component will contain several attributes, including ‘objectName’, ‘searchString’, ‘records’, and ‘selectedRecord’. It will also include an input field for the user to enter their search criteria, a dropdown menu to select the object to search for, and a list of results returned by the Apex class.

Here is an example of what the Aura Component might look like:

Step 3: Create a JavaScript Controller:

The final step is to create a JavaScript controller to handle the user interactions and make calls to the Apex method we created in Step 1.

In this controller, we will write methods to handle the search, select, clear, and cancel actions. Here is an example of what the JavaScript controller might look like.

js-meta.xml:

Now we have set it’s path to Record Page in aura component file using “implements” attribute.

Next, we will see how to set up this aura component custom lookup in salesforce org.

Setting up the aura component custom lookup in Salesforce org.

Click on the setting icon in vs code there you find the Command Palette option click on it or Use ctrl+shift+p (keyboard shortcut).

Search open default org. It will redirect to your default org in which you have created the project.

Next, open any of the objects where you want to set this custom lookup, and then

  • Click on the setup gear icon
  • Click on the edit page and
  • Select the custom file which you have created
  • Drag and drop where you want to use in that page
  • Now save and activate it.

Now you have just created a custom lookup using Aura Component. You can see the changes in which object record page you have created.

Below is an example of what it looks like. Whatever object you will select from the Dropdown, here I have created 3 objects Account, Contact, and Opportunity, they will show you the records and you can select the record to display it on the search field and click on the cancel icon to remove that record and choose another record.

The Below Image shows how it looks when you click on any record:

Conclusion:

With the knowledge gained from this blog, you can now easily create your own custom lookup components and tailor them to your specific needs. Be sure to try out the solution and stay tuned for our upcoming blogs. Till then, happy coding!

No Data Found.

Related Articles
Salesforce AI Adoption_ Proven Strategies to Overcome AI Implementation Challenges

AI is no longer a future concept inside the Salesforce ecosystem; it has become the operational layer behind sales, service, marketing, automation, and customer engagement. But while businesses are investing heavily in AI-powered CRM transformation, many organizations still struggle with one major challenge: successful Salesforce AI adoption. The problem is not access to AI tools. […]

Read More
Multi-Agent Architecture Will Define the Next Phase of Salesforce AI Innovation - Predictions Through 2030

Over the years, Salesforce hasn’t just grown, it has continuously reshaped itself, moving far beyond its early CRM identity into something much larger. From being just a CRM platform to becoming a full-scale enterprise ecosystem, every phase has been driven by a deeper layer of intelligence. Now, that next layer is Salesforce AI. Today’s generative […]

Read More
Salesforce Agentforce 360_ The Future of AI-Powered Customer Service

Customer service is changing very fast now, and businesses are slowly moving beyond basic chatbots and automated replies. Companies want systems that can actually understand context, respond intelligently, and help teams solve customer issues faster without creating more manual work. That is exactly where Salesforce Agentforce 360 is getting attention across the Salesforce ecosystem. Instead […]

Read More
Why is Salesforce partnering with the biggest names in AI_ Like Salesforce, Stripe, and OpenAI

Something interesting is happening in the CRM world right now, and it’s not just about adding AI features. Salesforce isn’t trying to build everything alone anymore. Instead, it’s partnering with some of the most powerful AI and cloud players like OpenAI, Stripe, Anthropic, and NVIDIA. This shift signals something much bigger than integrations. It’s about […]

Read More
Sales Cloud Latest Updates_ What’s New in Salesforce Cloud and Why It Matters for Your Business

If you’ve been using Salesforce Cloud, you already know one thing, it never stays the same for long. Every new release brings changes that directly impact how sales teams work on a daily basis. The latest updates in Salesforce Cloud Services, especially around Sales Cloud that now known as Agentforce Sales, are not just minor […]

Read More
Salesforce & Google Cloud AI Agents_ Powering Cross-Platform Automation with Deep Context

Something fundamental has shifted in enterprise automation. It’s no longer about connecting tools; it’s about enabling systems to think, decide, and act across platforms. The collaboration between Salesforce and Google Cloud is driving this shift through AI agents that operate with deep context and execute end-to-end workflows. This blog breaks down how Salesforce Google Cloud […]

Read More
Our Location worldwide
Indian Flag India
3rd Floor, A-10, Pegasus Tower, Sector 68, Noida, Uttar Pradesh 201301 +91-1203239658
United States of America Flag USA
333 West Brown Deer Road Unit G – 366 Milwaukee WI, USA 53217 +1(262) 310-7818
United Kingdom Flag UK
7 Bell Yard, London, WC2A 2JR +44 20 3239 9428
Canada Canada
HIC Global Solutions INC
6D - 7398 Yonge St #1124 Thornhill, ON L4J 8J2 Canada +1(262) 310-7818