How To Identify a Date Which is “X” Business Days From a Particular Date in Salesforce?
January 21, 2019How to Setup Globally Salesforce Email
January 21, 2019Problem 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.
Solution :
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.