infometry logo

Problem Description : 

Salesforce has limited support for “Search” functionality. Users can only search values stored in the text fields/controls. Salesforce users cannot search values in Multi-Select objects as it is not supported. Multi-Select values are stored as text strings separated by semicolons in the database. The majority of the business savvy customers want to search on all/any field on the screen.

Technical Challenges (to Developers)

A suggested workaround for search is to create a text field behind the scene to store each of the searchable values, to make it searchable by the Salesforce application.

Approach :

Instead of creating multiple text fields to store data, it is optimal to use JSON format to store all the content in a single text field.

Technical Solution :

· Create a new Custom Formula field which returns a text value.

· Use the following apex code to populate the Created field.

     for (related object  c : newRecords) {            c.JSon_Text__c=JSON.serialize(c).left(100000);        }

· The New text field will have all the fields of that related object with their values in json format.

Advantage :

This solution is scalable and JSON objects writes all the values in the fields on the Salesforce page. One need not have to add each field/values separately, Doesn’t impact much on performance, easy to implement, easy to migrate.

Issues :

All the values becomes searchable, Sometimes search picks up the records which has substring “and” , “new” etc. Take note that since lookup fields are stored in the form of id hence it is not searchable.

Conclusion :

All fields including date, picklist, multi-picklist fields become searchable using this approach.

[evp_embed_video url="http://www.infometryinc.com/wp-content/uploads/2019/02/Salesforce_Search_content.mp4" poster="http://www.infometryinc.com/wp-content/uploads/2019/01/search.png" template="mediaelement" width="1060" height="795" ]