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!

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
Dreamforce 2026 Day 3 Key Takeaways: Slack Becomes the Front Door to the Agentic Enterprise

Dreamforce 2026 Day 3 brought a slightly different focus compared with the first two days. Instead of mainly introducing new AI layers, the sessions showed how these capabilities can become part of the everyday tools where teams are already working. The biggest theme across Salesforce Dreamforce Day 3 was Slack. Salesforce positioned Slack as the […]

Read More
Dreamforce 2026 Day 2 Keynotes: From AI Potential to Enterprise Action

Dreamforce 2026 Day 2 moved the conversation from what AI and agents can do toward how businesses can actually use them in everyday workflows. The focus was much more practical, with demos, customer examples, and new ways to scale agentic work. While Day 1 introduced the bigger AIforce vision, the second day of Salesforce Dreamforce […]

Read More
Dreamforce 2026 Day 1 Key Takeaways: Salesforce’s Agentic Enterprise Takes Shape

Dreamforce 2026 Day 1 made one thing clear: Salesforce is moving beyond AI assistance toward a more agentic enterprise where data, applications, business logic, and AI can work together in a much more connected way. The main keynote introduced AIforce as a new interface layer that brings Salesforce intelligence into the places people already work. […]

Read More
Salesforce Open CTI Retirement: What the 2028 Retirement Means for Your AI Strategy

The Salesforce Open CTI Retirement is coming, but there is more to it than simply replacing an old telephony setup. With AI and Agentforce changing how service teams work, this is a good time to rethink your entire voice strategy. If your business still relies on Open CTI, now is the time to understand what […]

Read More
Salesforce AWS: What the Partnership Could Mean for the Future of Enterprise Technology

The relationship between Salesforce AWS is no longer just about connecting two big technology platforms. It has been moving toward something much bigger: shared data, cloud infrastructure, AI models, agents, contact centers, and even how enterprises buy technology. The interesting part is where this goes next. Businesses are not only looking for another integration sitting […]

Read More
Salesforce Partnership with Databricks: Bringing Trusted Data and AI Together

Artificial intelligence is becoming a bigger part of how businesses operate, but AI is only as powerful as the data and context behind it. As organizations look for ways to connect customer data, enterprise systems, and AI-powered workflows, Salesforce has announced an expanded Salesforce partnership with Databricks to help make that possible. The collaboration focuses […]

Read More
Our Location worldwide
Indian Flag India
3rd Floor, A-10, Pegasus Tower, Sector 68, Noida, Uttar Pradesh 201301 +91-1203669505
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
CA Flag Canada
HIC Global Solutions INC
6D - 7398 Yonge St #1124 Thornhill, ON L4J 8J2 Canada +1(262) 310-7818