Search Mechanism

Intro

3B Onboarding comes with a configurable search mechanism that’s embeddable and extensible. The mechanism is designed to find contacts based on evaluating search conditions that are pre-configured, however more complicated business logic can also be added to enhance the search capabilities of the mechanism.

Pre-Built Conditions

Out of the box, the search mechanism allows you to query on fields directly on the contact or even field paths to an unlimited levels deep. As an example, you can filter contacts by accessing the Parent Account’s Owner user record via the path Contact -> Account (through Account field) -> Parent Account (through ParentAccount field) -> Owner (through Owner field) -> Name.

Furthermore, the search mechanism supports searching for matches on child-related objects.These two conditions must evaluate to “true” (aka must be a match) in order for a contact to be returned as a positive match.

Target types

Currently, we support all field types apart from Rich Text Area, Long Text Area, Password/Encrypted field when performing a search. Furthermore, we respect field permissions and the running user doesn’t have access to a field, they won’t be able to run search on it.

Here are the primary field types that we support:

  • Text
  • Picklists and multi-picklists
  • Date
  • Date Time
  • Time
  • Checkbox
  • Lookup Reference
  • Formula


When selecting a field, we will automatically provide you with a field for data entry that matches the target field. This means that if you select a reference field, the value selector for your condition will be a search drop down field that lets you select a record from a list.

Conditions

When building a search filter for the standard search conditions, you can build  AND/OR conditions that are wrapped in condition groups. You can also add multiple condition groups with an AND/OR relationship between them.

So, let’s take the following example:

I want to find candidates, which have a 3B Application that is in status “In Progress” and their contact Status is not “Archived” or contacts that have a 3B Placement that is in status “New” or “In Progress”.

You would need to build your filter using two condition groups. In the first condition group, you will set the “Apply when” to “All conditions are met” and add the two conditions.

In the second condition group, you will need to select “Some conditions are met” in the “Apply when” section and add the two conditions.

Finally, you will need to select “Some conditions are met” to the Apply When option common across the condition groups.

Embedding

The search component is an LWC component that can be embedded on any salesforce or even in a standalone Lightning Page using the Lightning App Builder.

When embedded through the Lightning App Builder, you will be asked for a “Code” to be set on the component settings section. This code plays an important role to add uniqueness and route requests successfully to the server. Make sure that the code value is unique for each location this component is embedded in.

Selections Handler

We can create custom components that can receive the selected contacts from the identified search results and process them for any business rules. Both the Search Component and the Selected Candidates handler components need to be added on the same page and they need to share the same pairing code.


Out of the box, we deliver two components that integrate with the search component –

  • “Invite Selected Candidates” – used when the search component is supposed to add selected candidates as Session Invitees to a Session*(link to article)
  • “Shortlist Selected Candidates”– used when the search component is supposed to add selected candidates as Shortlist Links to a Shortlist*(link to article)

You can create your own custom component to handle selections by implementing the following code signature:

    _pairingCode;
    _pageReference;
    _topic;
    /**
     * Set from the App Builder, this is the unique pairing code
     * that is shared with the Search Component
     */
    @api
    get pairingCode() {
        return this._pairingCode;
    }

    set pairingCode(value) {
        this._pairingCode = value;

        this.setTopic();
    }

    _windowEventListeners = {
        searchResults: null, 
        searchError: null
    }

    /**
     * Gets the page reference and sets the topic
     */
    @wire(CurrentPageReference)
    receivePageReference(data) {
        if (data) {
            // The assumption here is that for a given page rendering the current page reference object will
            // stringify identically even when performed in two separate components (the worker search and
            // its paired custom component).
            this._pageReference = JSON.stringify(data);
            
            this.setTopic();
        }
    }

    /**
     * Sets component topic
     */
    setTopic() {
        if (!this._pairingCode || !this._pageReference) {
            // Do nothing if the pairing code or page reference is not yet available
            return;
        }

        this._topic = this._pairingCode + '/' + this._pageReference;        
    }

    connectedCallback(){
        debug('ShortlistSelectedCandidates', this.recordId);
        this._windowEventListeners.addSelected = this.addToList.bind(this);
        window.addEventListener("action_selected_contacts", this._windowEventListeners.addSelected);
    }
    
    disconnectedCallback() {
        window.removeEventListener("action_selected_contacts", this._windowEventListeners.addSelected);
    }

    @track isLoading = false;
    @track selectedContactIds = [];
    addToList(event){
        this.selectedContactIds = event.detail.selectedContactIds;
        debug('addToList ', event.detail);
        ... Do something with selected candidates
    }

    reportResults(isSuccess){
        window.dispatchEvent(new CustomEvent("add_to_list_results", {
            detail: {
                topic: this._topic,
                isSuccess: isSuccess,
                selectedContactIds: this.selectedContactIds
            }
        }));
    }

Customization

The results table’s columns can be customized to remove the default columns and replace them with different ones. This is done by configuring the Custom Metadata “Search Results Table Headers”.

Loading custom business rules requires support from our team. Please reach out to our support team at support@3bonboarding.com.