![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpvnmYg7FEm1wlCuAQJTOmCBIrAW5dj1xJAxDkChHtAfgZlBEqTVO9KUqBj6UmnCLaUgcJmiOv_qxaNB8tsNvOc-BCfnXEu2oZuEfh8N-0GB43_OvCAJqq5wuk5jAIYbmNVm7Ufb5x0h8/s400/soundex.gif)
Ever wanted to get some more "fuzziness" in your detection rules? Then Soundex as a phonetic algorithm will be your friend. There are some caveats but for some applications it might be useful. The nice thing is, that it's super-easy to implement.
Let's consider two options (in your project you might want to go for a "best of both worlds" approach by using both):
Method1 Clientside: Generating the Soundex-Code at the onSave event
Pro: Quick and easy implementation
Con: Will not work on imports or Bulk Operations
Step by step:
1) add a custom field "new_soundex_lastname" to the desired entity (lead, account, contact or any custom entity)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgskH12xKI6wNFV9I-aOoODOQMWLqGy_hVyhVOdaoUHGVTXQvROvrzxV2TmwWEJcSXVvLH9dNZvIWfU-vHjP-KyIkLcxIfrXOOczJTNvlBGt7olDbkCoudGosv0LKSiF-Q_cSq8XlfM0tk/s400/ScreenHunter_03+Mar.+05+09.01.gif)
2) add the field to the form
3) add this onSave event:
function soundex(str) {
// original from http://phpjs.org/functions/soundex:520
var i, j, l, r, p = isNaN(p) ? 4 : p > 10 ? 10 : p < 4 ? 4 : p;
var m = {BFPV: 1, CGJKQSXZ: 2, DT: 3, L: 4, MN: 5, R: 6};
var r = (s = (str+'').toUpperCase().replace(/[^A-Z]/g, "").split("")).splice(0, 1);
var sl = 0;
sl = s.length;
for (i = -1, l = sl; ++i < l;) {
for (j in m) {
if (j.indexOf(s[i]) + 1 && r[r.length-1] != m[j] && r.push(m[j])) {
break;
}
}
}
return r.length > p && (r.length = p), r.join("") + (new Array(p - r.length + 1)).join("0");
}
crmForm.all.new_soundex_lastname.DataValue=soundex(crmForm.all.lastname.DataValue);
4) add a duplicate rule & publish
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6SfMUStQuzmIrCSvxoJmeZIt4KUNWYZWSUN-bzcm0iSCHmWrXEvdll1WzpZeW_jb1wWNOwM17H7PIVOV996omRqq0H7EVA5IVmuYd3GPW6esTcSmNsHjd302-52tUXWWZSnZP8PhPW3Q/s400/ScreenHunter_05+Mar.+05+12.42.gif)
5) enjoy life without unneccessary duplicates ;-)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfMTrXVffxa8Zre-SgdbzIMDkfaQOyoywY0VM4gHvdYgKI1uRVSGjxKAaQFMZiWaVG_FP8YTijrx0ktQ6fvh7t395-dh7lHumyfLfwKFpuevHwqVWKqKs4Fb2ImUux6k8hGQY7pQItoug/s400/marykate-and-ashley.jpg)
Method 2 Plugin: Firing at Pre-Create event
Pro: Works on Imports
Con: A bit more work