Nue Knowledge Center

Nue Docs navigation

search
clear
/

Lookup Filter Plugin

This article outlines how we can add a custom lookup filter plugin to apply additional filters to a Lookup Component displayed on Nue UI in Nue on Salesforce.

 


 

Implement Plugin Interface

The parameters of this plugin interface include the following: 

 

  • Object API Name: The object’s API name, e.g., Ruby__LineBucket__c
  • Lookup Field API Name: The lookup field’s API name, e.g., Ruby__BillingContact__c
public class DemoSearchPlugin implements SearchLookupOptionPlugin{

    public List<LookupOption> searchLookupOptions(String objectApiName, String lookupFieldApiName, String queryInput, Map<String, Object> values) {
        String condition = '%' + queryInput;
        List<Contact> contacts = [SELECT Id, Name, FirstName, LastName FROM Contact WHERE Name LIKE :condition LIMIT 10];
        List<LookupOption> lookupOptions = new List<LookupOption>();
        for(Contact contact: contacts) {
          LookupOption option = new LookupOption();
          option.Id = contact.Id;
          option.Name = contact.Name;
          option.OptionName = contact.Salutation + ' ' + contact.FirstName + ' ' + contact.LastName + ' (' + contact.Title + ')';
          option.Category = 'Primary Contacts';
          lookupOptions.add(option);
        }
        return lookupOptions;        
    }
}

 

Register the Plugin using Custom Setting 

  • Navigate to Nue on Salesforce > Settings > Custom Settings, and search for Lookup Search Plugin, and click ‘Manage’.  
  • Add a new Lookup Search Plugin value, and enter the Lookup Field API Name and Object API Name.  The Plugin Class Name has to match the Apex class name you created earlier.