Loading

Partial search term may not return results due to tokenization

Udgivelsesdato: Dec 26, 2023
Beskrivelse

The How Does Search Break Up Information? documentation details how tokenization of data works for Salesforce search indexing.

There could be times where users may want to search for a part of the value in their Searchable Field, but the way the term is tokenized may not yield expected results.

 

Note: If your search query contains punctuation or special characters and you’re not getting the right results, try your query with white spaces in place of the punctuation. Also, tokenization may differ depending on the field. For example, a phone number in a record's phone number field may be tokenized differently from one in a Chatter post.

 

Example:

Let's say we have a Car Dealership where customers call to schedule an appointment for an oil change; the representative would need the last 4 Digits of the Vehicle Identification Number (VIN) to identify their customers, for example '1HGBH41JXMN109186'.

Here's the list of tokens the representative can use to search for its customer:

 

Indexed TermSearch Term
1HGBH41JXMN1091861HGBH41JXMN109186
HGBH
41
JXMN
109186


When the representative searches for '9186' they get no results, appending a wildcard at the beginning of the search term does not return the expected results, i.e., searching for *9186 does not return '1HGBH41JXMN109186'. 

Note: Appending a wildcard at the beginning of the search term is only supported in Standard Lookups. Please note that Standard Lookups are available in Classic UI only. 

Ideally, Users would need to search using one of the tokens mentioned above to return the record. However, with the help of a little behind the scenes customization it's possible to return records via searching the last 4 digits of the value in the VIN# (VIN__c custom field for example).

Løsning
 
An example workaround for the scenario above is to create a custom field, workflow rule, and a workflow action to populate a searchable text field with the last 4 digits from the sample custom field, VIN# (VIN__c).


Step 1: Create a custom field

1. Steps for Classic: Setup | Customize | Object | Fields | New.
    Steps for Lightning: Setup | Object Manager | Object | Fields & Relationships | New.
2. Choose an appropriate Field Label, Length, and Description (optional). Click Next.
3. Select the Visible check box twice (this would make the field hidden). Click Next.
4. Deselect Add Field in Step 4. Add to page layouts. Click Save.
 

Step 2: Create a workflow rule

1. Steps for Classic: Setup | Create | Workflow & Approvals | Workflow Rules.
    Steps for Lightning: Setup |Process Automation | Workflow Actions | Workflow Rules.
2. Click on New Rule. Select the standard or custom object from the Object dropdown then click Next.
3. Give an appropriate Rule Name & Description (optional).
4. Select created, and every time it’s edited under Evaluation Criteria.
5. Under Rule Criteria, select formula evaluates to true on the dropdown for 'Run this rule if the.'
6. Enter 1<>0 in the formula editor then click Save & Next.


Step 3: Create a workflow action

  1. Under Immediate Workflow Actions, click on Add Workflow Action and select New Field Update.
  2. Enter a Name, Unique Name, and Description (optional).
  3. Select the custom field you created in step 1.
  4. Under Specify New Field Value, select Use a formula to set the new value.
  5. Click Show Formula Editor, click on Insert Field, enter Left(VIN__c , 4) then click Save.
  6. Click on Done then Activate.

Now, navigate to the record that wasn't part of your search result and perform a simple edit and save (no need to make any changes on the record, this step is done to fire the workflow action & re-index the record). Note that the record is now returned in the search result when you search for just the 4 digits of the VIN#.
Vidensartikelnummer

000383915

 
Indlæser
Salesforce Help | Article