[Stable]

Searches for records in your organization’s data.

sf_search(
  search_string,
  is_sosl = FALSE,
  guess_types = TRUE,
  api_type = c("REST", "SOAP", "Bulk 1.0", "Bulk 2.0"),
  parameterized_search_options = list(...),
  verbose = FALSE,
  ...
)

Arguments

search_string

character; string to search using parameterized search or SOSL. Note that is_sosl must be set to TRUE and the string valid in order to perform a search using SOSL.

is_sosl

logical; indicating whether or not to try the string as SOSL

guess_types

logical; indicating whether or not to use col_guess() to try and cast the data returned in the recordset. If TRUE then col_guess() is used, if FALSE then all fields will be returned as character. This is helpful when col_guess() will mangle field values in Salesforce that you'd like to preserve during translation into a tbl_df, like numeric looking values that must be preserved as strings ("48.0").

api_type

character; one of "REST", "SOAP", "Bulk 1.0", or "Bulk 2.0" indicating which API to use when making the request.

parameterized_search_options

list; a list of parameters for controlling the search if not using SOSL. If using SOSL this argument is ignored.

verbose

logical; an indicator of whether to print additional detail for each API call, which is useful for debugging. More specifically, when set to TRUE the URL, header, and body will be printed for each request, along with additional diagnostic information where available.

...

arguments to be used to form the parameterized search options argument if it is not supplied directly.

Value

tibble

Note

The maximum number of returned rows in the SOSL query results is 2,000. Please refer to the limits HERE for more detail.

Examples

if (FALSE) {
# free text search
area_code_search_string <- "(336)"
search_result <- sf_search(area_code_search_string)

# free text search with parameters
search_result <- sf_search(area_code_search_string,
                           fields_scope = "PHONE",
                           objects = "Lead",
                           fields = c("id", "phone", "firstname", "lastname"))

# using SOSL
my_sosl_search <- paste("FIND {(336)} in phone fields returning",
                        "contact(id, phone, firstname, lastname),",
                        "lead(id, phone, firstname, lastname)")
sosl_search_result <- sf_search(my_sosl_search, is_sosl=TRUE)
}