This is a basic SOSL apex invokable class, made primarily for use in flows. It was developed for use with DatatableFSC, but can be used in any flow where a collection should be returned from a search. The benefit of using this approach is that you take advantage of Salesforce's fuzzy logic in search, where you can miss leading or trailing letters, or use close names, e.g. a search for Davi or Dave will return David.
You can install the package from these links:
The invokable class takes a set of variable, and returns a collection of records found during the search.
First, collect the queries. You can use a single query, or a list. In the example below, I'm looking for contacts with a name, email or phone number.
If you're using more than one query, you'll need to add them to a list. This is done by setting up a text type collection variable:
Then you need to assign each query to that list. In the example below I'm checking whether the query had a value before I add it, so I don't add an empty string:
Then I pass that list into the invokable action, along with the SObject type, and a scope or where clause if required. The process returns a list of ID's, which I store in another text collection variable:
If I need more than the ID, I iterate through the results, adding the records to a record collection variable:
Then I present it in a datatable, following the instructions in the DatatableFSC documentation.
From there, I can select a record, edit inline, or take other actions.
This project is licensed under the GNU GPLv3 License - see the LICENSE.md file for details