FuzzyWuzzy Algorithm with Salesforce Flow
In this article, I’d like to show you about my porting result from xdrop’s Java FuzzyWuzzy algorithm (originally from python FuzzyWuzzy)
Why FuzzyWuzzy in Salesforce?
- This package will help you to automate a bunch of boring stuffs related to string processing in Salesforce
- Previously, I used Python FuzzyWuzzy library to process my strings. So to have this function, I needed to expose an API to serve requests from Salesforce and Salesforce will need to callout to that API. But with this, no more callout!
- Currently, Salesforce has similar function which is Contains, but with sometimes, contains is not enough because contains doesn’t care about typos and abbreviation when we’re matching strings. So, you’ll need a new function to achieve this
So, what is FuzzyWuzzy?
FuzzyWuzzy (or Fuzzy Matching) is a method to calculate similarity in percentage between 2 strings. It uses Levenshtein Distance to calculate the similarity.
How to use Fuzzywuzzy in Salesforce Flow?
a. Install this package to your Salesforce org (don’t forget to change login to test.login if you want to install in sandbox): https://login.salesforce.com/packaging/installPackage.apexp?p0=04t2w000009F5gY
source code: github
b. After package installed, you’ll have a new Apex Action to execute your FuzzyWuzzy operation. The Apex Action name is: FuzzyWuzzy Scoring
c. There will be 3 Inputs and 1 Output you’ll need to config.
FuzzyWuzzy Logic: See Supported FuzzyWuzzy logic below
String01: 1st String you want to compare
String02: 2nd String you want to compare
Score: Similarity score (in percentage)
Supported FuzzyWuzzy Logic:
- SimpleRatio :
Allows us to calculate the Levenshtein distance similarity ratio between the two strings (sequences)
Allows us to perform substring matching. This works by taking the shortest string and matching it with all substrings that are of the same length.
The good news is you’ll be able to test the function before you install the package. You can visit this and you’ll have an access to User interface to test the FuzzyWuzzy flow.
Enjoy and drop a comment if you have troubles or feedbacks for my writing. I’ll try my best to help you folks!