---
schema_version: "1"
id: 5f5134240adfbb11a2d19bc2c2194fb459322b1767d48693be089727f18b795e
title: SearchUtils Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_class_DataSource_SearchUtils.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_DataSource_SearchUtils.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 0e822a0f3024c6f9c79a8e895500500a022317bf7bf95b71c4155fe76c862c38
description: Helper class for implementing search on a custom adapter for Salesforce Connect.Queries all the tables and returns each row whose designated name field contains the search phrase.
---
# SearchUtils Class

Helper class for implementing search on a custom adapter for Salesforce Connect.

## Namespace

[DataSource](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_DataSource.htm "The DataSource namespace provides the classes for the Apex Connector Framework. Use the Apex Connector Framework to develop a custom adapter for Salesforce Connect. Then connect your Salesforce organization to any data anywhere via the Salesforce Connect custom adapter.")

## Usage

We recommend that you develop your own search implementation that can search columns in addition to the designated name field.

- **[SearchUtils Methods](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_DataSource_SearchUtils.htm#apex_DataSource_SearchUtils_methods)**

## SearchUtils Methods

The following are methods for SearchUtils.

- **[searchByName(searchDetails, connection)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_DataSource_SearchUtils.htm#apex_DataSource_SearchUtils_searchByName)**  
    Queries all the tables and returns each row whose designated name field contains the search phrase.

### searchByName(searchDetails, connection)

Queries all the tables and returns each row whose designated name field contains the search phrase.

#### Signature

public static List<DataSource.TableResult> searchByName(DataSource.SearchContext searchDetails, DataSource.Connection connection)

#### Parameters

- **searchDetails**:
    
    Type: [DataSource.SearchContext](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_DataSource_SearchContext.htm#apex_class_DataSource_SearchContext "An instance of SearchContext is provided to the search method on your DataSource.Connection class. The instance corresponds to a search or SOSL request.")
    
    The SearchContext class that specifies which data to search and what to search for.
- **connection**:
    
    Type: [DataSource.Connection](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_DataSource_Connection.htm#apex_class_DataSource_Connection "Extend this class to enable your Salesforce org to sync the external system’s schema and to handle queries, searches, and write operations (upsert and delete) of the external data. This class extends the DataSourceUtil class and inherits its methods.")
    
    The DataSource.Connection class that connects to the external system.

#### Return Value

Type: List<[DataSource.TableResult](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_DataSource_TableResult.htm#apex_class_DataSource_TableResult "Contains the results of a search or query.")\>