Skip to content

Implemented dynamic SOSL

Pre-release
Pre-release
Compare
Choose a tag to compare
@jongpie jongpie released this 19 Feb 22:28

Dynamic SOSL has been implemented with minimal changes to how the framework is used.

  • Added ISObjectRespository.List<SObject> searchInAllFields(String searchTerm); to require one basic SOSL method per object
  • Public methods can switch between using SOQL and SOSL by making 2 changes:
    1. Call the getSearchQuery method instead of getSearchQuery. 2 parameters are expected, String searchTerm and SObjectRepository.SearchGroup searchGroup
    2. Change return (Lead)Database.query(query); to return (Lead)Search.query(query)[0];. This is because SOSL returns a list of lists, so we need to get the first list from the... list of lists (this seems silly to explain).
  • All other protected & private methods are shared between the SOQL & SOSL queries, with one exception: SObjectRepository.setAsUpdate() can be called, but is ignored for SOSL since SOSL does not support it. A debug statement with LoggingLevel.WARN will be shown in the logs in this situation.