Nearly one year ago, we listed our product “Lightning Universal Lookup Component” on AppExchange. Over time, we were trying to improve our product according to users’ propositions and requests, but we released the most potent updated version of the LULC package this year.

Now we would like to introduce you to the new version, 2.10. But first, let us say a few words about the component in general. This would be relevant for those unfamiliar with our product yet. 

Introduction to the Lightning Component

At the very beginning, our component could be beneficial only for developers because Lightning did not contain any element with specific customization that could be applied for other users.

However, Salesforce release Spring 18 opened new features to us, and now we can use Lightning in Flow. As soon as this update was released, we received many requests to enable this feature in our component. So we decided not to hesitate and start implementing it.

Our Lightning Universal Lookup Component is destined to make operations of Salesforce developers and Administrators less time-consuming. If you prefer to save time and simplify the workflow process, you may easily install our package and start using it straight away. This component looks like a standard one; customization is simple, and it works everywhere. Sounds tempting, right? And what about new updates?

Lightning Universal Lookup Component Update

The most important update is a performance improvement of lookup search. The new updated version transfers fewer requests to the serves, and as a result, it became more powerful. To reduce the number of requests to the server, we used a “delay query.” Therefore, we are going to the server only when you stop typing the text.

Generally, it works this way:

clearTimeout (window.timer);

window.timer = window.setTimeout(

 $A.getCallback(function() {

   // Do search

 });

}), 400);

We have also added a spinner to make it more user-friendly. Check the demo below:

User-added image

Method of fireChanging is updated

One of the most critical updates in the second version was in the method of fireChanging that allows updating selected values from js controller. With this update, you do not have to create extra attributes if you want to use this method, pass a new value as a parameter.

Component:

<aura:attribute name="selectedId"

                                   type="String"/>

<aura:attribute name="newValue"

                                   type="String" />

<l_lookup:Lookup aura:id="lookupId"

                                        objectType="User"

                                        selectedRecordId="{!v.selectedId}" />

<lightning:button label=”Change”

  onclick=”{!c.changeIt}” />

   Action in controller to change record Id:

      changeIt : function(cmp, event, helper) {

                                             var newVal = cmp.get("v.newValue");

                              cmp.find("lookupId").fireChanging(newVal);

                 }

You should not be worried if you used the previous version, since it would also work as it used to before.

Some new useful attributes

By default, the component works as a standard Salesforce lookup field, and when the lookup is in focus, it shows the list of recently viewed records. This feature helps users to search records quicker. However, once in a while, this feature may not be useful. This scenario happens when you have some top records users use more often. With the new attribute dropDownQuery, you can define criteria by which dropDown will be populated instead of a standard list of recently viewed records. Moreover, with dropDownLimit, you can configure the number of records in the drop-down suggestion list. By default dropDownLimit = 5.

In case the attribute is empty, a standard process will work, which shows 5 recently viewed records if showFiveRecent is not false.

If you use queryCondition, it will be added to dropDownQuery criteria.

Example:

<aura:attribute name="selectedRecordId" type="String" default="" />

<c:Lookup aura:id="myLookup"

             objectType="Contact"

             selectedRecordId="{!v.selectedRecordId}"

             dropDownQuery="IsActive__c = true"

             dropDownLimit=”3” />

Demo:

User-added image

It’s a new optional attribute that allows sorting your records. You can define the list of fields to sort the records.

Salesforce documentation: ORDER BY in SOQL

E.g.:

<aura:attribute name="selectedId" type="Id" />

// Order by Contact Name A-Z

<c:Lookup aura:id="myLookup"

                        objectType="Contact"

                        selectedRecordId="{!v.selectedId}"

             orderBy=”Name” />

User-added image

Also you can define several fields by comma separator:

// Order by Name and Created date

<c:Lookup aura:id="myLookup"

                        objectType="Contact"

                        selectedRecordId="{!v.selectedId}"

                        orderBy=”Name DESC, CreatedDate” />

Bottom Line

Our Lightning Universal Lookup Component has become even more flexible in version 2.10. Now you are able to adjust your lookup according to your language. Translate it if necessary. For more information, you may read the documentation.

Hope this article was helpful. If you have any questions or propositions, please, do not hesitate to leave your comments below or send us an email to contact@synebo.io.

Editor’s Note: This post was updated for accuracy and comprehensiveness in December 2021.