SOQL: Bulk Fuzzy Searching salesforce

public static List<Account> findCandidates(String potentialName){
    if (String.isBlank(potentialName)) return null;
    List<Account> candidates = [SELECT Id FROM Account WHERE Name = :potentialName];
    if (!candidates.isEmpty()) return candidates;

    List<String> partialMatches = new List<String>();
    for (String fragment : potentialName.split(' ')){
        partialMatches.add('%' + fragment + '%');
    }
    return [SELECT Id FROM Account WHERE Name LIKE :partialMatches];
}

No comments:

Featured

What is Cryptography in salesforce and what are all the algorithms provided by them ?

A). It is a security protocal between two systems. Lets say we are integration two systems without any encrytion mechanism then hackers wil...

Popular